test(relinker): decode relinker output as UTF-8 in the path-checking tests #9513
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/9513"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by harisibrar1 on 2026-10-21T23:57:32Z.
What
The relinker writes paths to stdout, stderr and its patch manifest as UTF-8, but seven relinker test scripts decode them with the locale encoding (
subprocess.run(..., text=True)with noencoding, and a bareread_text()). On Windows that is the ANSI code page. The relinker tests keep their temporary files under<build>/core/relinker/test-temp(core/relinker/CMakeLists.txt), so with a build directory that contains non-ASCII characters (for example under a user profile likeC:/Users/José/) the asserted paths no longer match and these tests fail, e.g.test_input_file.pysees the relinker path...\ünï\...as...\�n�\....#2692 fixed the relinker itself for such directories; these tests still read its output with the locale encoding. Affected:
game_patches,guest_needed_modules,guest_symbol_names,input_file,input_preservation,relinker_executables,tls_diagnostics. The change passesencoding="utf-8"to the relinker runs in those scripts and reads the patch manifest as UTF-8, astest_input_nonascii.pyalready does. Runs of the converted programs are unchanged.Tested
Windows 11, WinLibs GCC 15.2.0 r7, relinker-only build (
-DANYPS5_RELINKER_ONLY=ON -DBUILD_TESTING=ON), Python 3.14, on maina6dcea927, build directoryC:/Users/Haris/ANYPS5/pathhunt/ünï/b:tls_diagnostics,relinker_executables,game_patches,guest_symbol_names,input_preservationandinput_filefail on path assertions (0/6 pass); rerunning them withPYTHONUTF8=1passes, confirming the cause. With this branch all six pass.guest_needed_modulesgets past its path assertion and then stops where this machine's Smart App Control blocks the converted executables (WinError 4551), which also happens in an ASCII build directory.autorun_exit_status,windows_dependency_diagnostics,windows_diagnostic_fixture_isolation) that throwfilesystem error: Cannot convert character sequencefrompath::string(); that is a separate issue for a follow-up.encoding="utf-8"(27 call sites in 7 files).tools/check_conventions.py --base origin/mainpasses;tools/pr_overlap.py --branchreports no overlap with open pull requests.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T00:09:34Z.
Review: APPROVED
Reviewed the current test-only diff: every changed relinker subprocess result is decoded explicitly as UTF-8, and the generated patch manifest is read as UTF-8, matching the relinker’s output contract and the existing non-ASCII path test. This leaves the executed programs and assertions unchanged. The PR reports Windows reproduction under a non-ASCII build path, six affected path assertions failing on main and passing on the branch, plus unchanged ASCII-path results; the
guest_needed_modulesSmart App Control failure is clearly isolated. All four relinker matrix jobs and ASan pass, as do current eligibility/intake/conventions/labels checks. I did not rerun the suite locally.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T02:05:53Z.
Review: APPROVED
Rechecked the current test-only diff and CI. The seven affected scripts now decode relinker output and the generated manifest explicitly as UTF-8, matching the relinker output contract; command execution and assertions are unchanged. The reported non-ASCII Windows build-path run distinguishes the path failures fixed here from the Smart App Control block that also occurs in an ASCII directory. Eligibility, conventions, intake and labels pass; Ubuntu, Windows, macOS arm64/x86_64 and ASAN relinker jobs pass. Product jobs are skipped. I did not rerun tests locally.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T04:20:39Z.
Review: DISMISSED
The test-only UTF-8 decoding change remains correct, and the reported non-ASCII Windows reproduction plus hosted Ubuntu/Windows/macOS/ASAN relinker matrix are useful. One repository requirement is now outstanding: this branch and its reported verification are based on main
a6dcea9279, while current upstream main isc61d20f548. Please rebase or merge current main and rerun the focused non-ASCII path checks and relinker matrix/conventions on the updated head. I found no additional code defect in the diff; this request is for the current-main rule. I did not run local tests.Imported from boykopovar/AnyPS5. Originally posted by harisibrar1 on 2026-10-22T04:58:17Z.
@MarcZX10 Rebased onto main
17f533556(head 58d6aca5c) and reran in the non-ASCII build directory (.../ünï/b, relinker-only, WinLibs GCC 15.2.0 r7, Python 3.14, Windows 11):tls_diagnostics,relinker_executables,game_patches,guest_symbol_names,input_preservationandinput_filepass 6/6 in two runs with this branch, and 0/6 with main's versions of the seven scripts.check_conventions.py --base origin/mainpasses andpr_overlap.py --branchreports no overlap with open pull requests.Imported from boykopovar/AnyPS5. Originally posted by fogydes on 2026-10-22T09:09:13Z.
Verified the diff shape and the leftovers claim. All thirteen converted call sites are exactly the ones whose assertions compare relinker-produced text against strings containing the temp path (five
run(..., text=True)-style decodes mixed withencoding="utf-8"sites, plus theread_text(encoding="utf-8")conversions across the seven path-checking scripts). I also went through the remaining unconverted sites (test_elf_header.py,test_dynamic_segment.py,test_call_zero_padding.py, etc.) and their output comparisons are exit codes and byte-image content only — no assertion compares a string that could carry the temp directory, so leaving them astext=True(locale-decoded) doesn't reintroduce the failure the PR fixes. The body's A/B evidence (main fails under a non-ASCII temp dir, the PR passes for the same runs) is consistent with the diff; the separate C++filesystemconversion errors the body discloses are a different layer and out of scope here. Nothing invented, no behavior claims added — this is the right, contained scope for the defect it targets.Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-22T10:26:11Z.
Review: COMMENTED
Tested on macOS (Apple M2 Max, macOS 27.2), relinker-only Release build, x86_64 under Rosetta with Xcode's
/usr/bin/python3(3.9.6), head 58d6aca5c merged onto main7e2ba73e4c, build directory.../mac-cpu-e1-ünï/x86.Red→green with a real non-UTF-8 locale. With the default locale everything passes (Python 3.9 coerces the C locale to UTF-8). With
LC_ALL=en_US.ISO8859-1:tls_diagnostics,guest_needed_modules,relinker_executables,game_patches,guest_symbol_names,input_preservation,input_file.So
guest_needed_modules, which Smart App Control blocked on your machine, does go red→green here.Leftover when a path byte is undefined in the code page. cp1252 has no mapping for 0x81, 0x8D, 0x8F, 0x90 and 0x9D. Those are the second UTF-8 byte of
Á,Í,Ï,ÐandÝ, so a profile likeC:/Users/Ángel/orC:/Users/Íñigo/hits them. In that case a locale decode raisesUnicodeDecodeErrorbefore any assertion runs. Whether the script compares paths no longer matters. macOS has no cp1252 locale, so I emulated it: asitecustomize.pymakeslocale.getpreferredencodingand_bootlocale.getpreferredencodingreturncp1252for Python 3.9 (build directory.../mac-cpu-e1-Ángel/x86):Ángeldirectory, main: 126/230 failing. This PR: 120/230 failing.UnicodeDecodeError: 'charmap' codec can't decode byte 0x81. In 119 of them the error comes fromsubprocess.run(..., text=True)while decoding relinker stdout/stderr that contains the build path (for exampletest_elf_header.py:135,cli/tests/test_help.py, and 33 cases oftest_tls_function_coverage.py). So the unconvertedtext=Truesites do fail under a non-ASCII directory, just not for theü/ïdirectory used in the PR.input_preservationstill fails with this PR, attest_input_preservation.py:378. That line isPath(f"{output}.desktop").read_text()with no encoding. It runs on every host, because thewindowsloop also covers the Linux target. The.desktopfile embeds the output path. Withüit decodes to mojibake and thestartswith("[Desktop Entry]\n")check still passes, which is why it didn't show up in your run.Suggestion: add
encoding="utf-8"to line 378 here, since it is in one of the seven scripts. With that one change,input_preservationpasses in the emulatedÁngelrun. The other 87 failing scripts could be a follow-up: either the same keyword, orENVIRONMENT PYTHONUTF8=1on the relinker Python tests incore/relinker/CMakeLists.txt.Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
Imported from boykopovar/AnyPS5. Originally posted by harisibrar1 on 2026-10-22T13:17:44Z.
@MarcZX10 Rebased onto main
8b3a6ba88(head6b1916a2e) and reran in the non-ASCII build directory (.../ünï/b, relinker-only, WinLibs GCC 15.2.0 r7, Python 3.14, Windows 11):tls_diagnostics,relinker_executables,game_patches,guest_symbol_names,input_preservationandinput_filepass 6/6 in two runs with this branch, and 0/6 with main's versions of the seven scripts.check_conventions.py --base origin/mainpasses andpr_overlap.py --branchreports no overlap with open pull requests.Imported from boykopovar/AnyPS5. Originally posted by THEMANnt on 2026-10-25T04:33:43Z.
Review: APPROVED
Reviewed
42961581e4c5dbc80fd860d493cc6d727ef2e318againstc8d34aa8f4d8058d57169cc1e423ba6db00faaf0. No actionable findings in this focused review.Source review: Inspected every changed call/file read. Explicit UTF-8 decoding matches relinker diagnostics, patch manifests and desktop entries while preserving existing arguments, assertions and timeouts. Native test-executable output calls were not indiscriminately changed.
Validation: Windows Python 3.11 with PYTHONUTF8=0 and non-ASCII temporary paths: head input_file and tls_diagnostics scripts passed against the existing local relinker, while both baseline scripts failed. Five other head/baseline scripts encounter compatibility mismatches with that older binary (missing options or changed output); those are not claimed as head passes or attributed to this patch. Hosted Windows job 121012044791, Build 40140822980, explicitly logs Passed for all seven affected suites: relinker_executables, game_patches, guest_needed_modules, guest_symbol_names, input_file, input_preservation and tls_diagnostics on its merged PR checkout. Conventions, whitespace and registration passed; full-product jobs were skipped.
Scope: Test decoding and synthetic fixtures; no local pinned relinker rebuild or real title/game run.