tests: report the failed load in the relocation-free control instead of a TypeError #1816
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1823"
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 R0Y00/Xbox2Windows. Originally posted by default-cybe on 2026-11-24T19:15:59Z.
Change
In
tests/cpu/native_reloc_free_check.py, the unreserved control loads theDYNAMIC_BASE-cleared copy withLoadLibraryExW. If that load fails, the childreports
base: Noneand theGetLastErrorcode. The diagnostic then formattedfree['base']with:#x, socpu_native_reloc_freestopped with:That error hides the Win32 error the child had reported. The test now prints the
whole child result, which is what the
RELOCS_STRIPPEDcontrol a few lines belowalready does:
This changes the failure message only. The pass condition is unchanged, and the
change has no effect on a host where the load works. It is an independent
problem in the check added for #77 and adjusted in #1040. One line changed.
Verification
Commit
757cea99onecc6e6ce. Windows 11 build 26300, portable MSVC 14.52 (noVisual Studio install), Debug preset. I built only the four inputs:
ucrtbased.dll) is not in System32, so theunreserved
LoadLibraryExWfails with 126 (ERROR_MOD_NOT_FOUND). Before thechange the test failed with the
TypeErrorabove. After the change it fails withthe
AssertionErrorabove, which names error 126.os.add_dll_directoryfor the toolchain andUCRT folders, through a
sitecustomize.pyoutside the repository), the test passeswith the change: the copy loads at its preferred base when nothing is reserved,
the reserved cases match 249 of 249
call_mixresults under Windows andpe_map,and the
RELOCS_STRIPPEDcase is refused with error 487 and "relocations stripped".check()on the real fixtures andreplaces
childso the unreserved control returns{'base': None, 'error': 126, ...}. Onmainit raises theTypeError. Withthe change it raises an
AssertionErrorthat contains'base': Noneand'error': 126.Tested:
cpu_native_reloc_freewith and without a loadable debug CRT, and theforced-failure check above before and after the change.
Not tested: the Release preset, a host with Visual Studio installed (debug CRT
in System32), and the CI
prpreset. That preset does not select this test.Evidence and follow-up
No new fixture. Error 126 on this host comes from the portable toolchain (the
debug CRT is on PATH, and Python's DLL search ignores PATH). It is not a bug in
the loader or in
pe_map, so this PR changes only the message.Checklist
AI use: I prepared this change with Conclave (model
cliproxy/claude-opus-5-5).It found the issue, wrote the one-line change and ran the checks listed above
on my machine.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T19:23:29Z.
Review: COMMENTED
Reviewed commit
757cea99979cd25e723c4d688347958ce417284b(tests/cpu/native_reloc_free_check.py): no P1/P2 findings.When the unreserved
DYNAMIC_BASE-clearedLoadLibraryExWcontrol fails, the child returns{"base": None, "preferred": <int>, "error": <win32_err>, ...}. Printing the wholefreedict inAssertionErroravoids theNoneType.__format__TypeErroron{free['base']:#x}and preserves the Win32 error code, matching theRELOCS_STRIPPEDunreserved control below it. The pass condition (free["base"] != free["preferred"]) is unchanged, and line 131 remains safe becausepreferredis always a non-zeroVirtualAllocinteger.Verification
git diff --check origin/main...HEAD— passedpython3 -B tests/bidi_controls_check.py— passed (1313tracked files, no bidirectional controls)757cea99979cd25e723c4d688347958ce417284b:--preset dev):cmake --build --preset dev --target cpu_import_original cpu_import_provider cpu_register_probe pe_map -- -j 8(3.18s)ctest --preset dev -R '^cpu_native_reloc_free$' --parallel 6 --no-tests=error --output-on-failure— 1/1 passed (cpu_native_reloc_free1.17s)/O2(--preset release):cmake --build --preset release --target cpu_import_original cpu_import_provider cpu_register_probe pe_map -- -j 8(0.29s)ctest --preset release -R '^cpu_native_reloc_free$' --parallel 6 --no-tests=error --output-on-failure— 1/1 passed (cpu_native_reloc_free1.22s)--preset dev,-R '^cpu_native_reloc_free$'):LoadLibraryExWfailure on the unreserved control (image + ".missing") with the PR change: failed withAssertionError: DYNAMIC_BASE cleared / windows: unreserved control failed: {'base': None, 'preferred': 2192559374336, 'error': 126, 'pairs': 249, 'matches': 0}.main's{free['base']:#x}: failed withTypeError: unsupported format string passed to NoneType.__format__.AI-assisted; commands listed were executed locally.