Repository navigation
recomp_census: fix UNW_FLAG_CHAININFO/CountOfCodes and decode .xdata unwind ops (RECOMP-CENSUS-XDATA-UNWIND) - #1249
Conversation
|
Independent run. Apple M5 Pro, macOS 27.2.1 (26B131), Python 3.14.2, LLVM from Homebrew. I merged On 12 hand-built version-1 unwind records,
Not tested against a reference: version-2 records ( |
|
#1249 | head db3ea85 (merged cleanly with main c7753ed) | Audited |
|
Independent run of #1249 (python -I, no build, no game; GPU not used).
Commands (one process each, from the repo root):
|
|
Merged after enlight3d's red/green check (check) (RTX 3090, driver 621.40, Windows 11) and a local re-check here. Merged after local re-verification: this PR merged onto AI-assisted (Claude Code, Claude Opus 5.5), merged for MoonEyes. |
What changed
Fixes two x64
.xdataUNWIND_INFOheader bugs intools/recomp_census.pyand adds fullUNWIND_CODEdecoding andUNW_FLAG_CHAININFOchain walking to report the SEH / frame-layout breakdown needed bydocs/mobile.mdNext Step #3 (arm64 SEH / unwind translation):Bug fixes in
tools/recomp_census.pyUNW_FLAG_*bitmask (UNW_FLAG_NAMES):UNW_FLAG_CHAININFOis0x4(per Microsoft x64 exception handling / LLVMWin64EH.h), not0x8(0x4was previously mislabelledFHANDLER, so real chained unwind entries were misreported asFHANDLERandCHAINEDwas never reported).CountOfCodes(unwind_flags):UNWIND_INFObyte 1 isSizeOfPrologand byte 2 isCountOfCodes;unwind_flags()previously returned byte 1 ascode_count..xdataunwind decoder & census (tools/recomp_census.py)parse_unwind_info(img, unwind_rva)decoding all 11 x64UNWIND_CODEopcodes (0..10:UWOP_PUSH_NONVOL,UWOP_ALLOC_LARGE2- and 3-slot forms,UWOP_ALLOC_SMALL,UWOP_SET_FPREG,UWOP_SAVE_NONVOL,UWOP_SAVE_NONVOL_FAR, v2UWOP_EPILOG,UWOP_SPARE_CODE,UWOP_SAVE_XMM128,UWOP_SAVE_XMM128_FAR,UWOP_PUSH_MACHFRAME), verified against LLVMWin64EH.h/Win64EHDumper.cppand Microsoft CoreCLRamd64/unwinder.cpp.((CountOfCodes + 1) & ~1) * 2before trailingExceptionHandlerRVA or chainedRUNTIME_FUNCTION.UNW_FLAG_CHAININFOchains with cycle detection and bounded depth (MAX_UNWIND_CHAIN = 64), aggregating fixed stack allocation, saved nonvolatile GPRs/XMMs, frame register/offset, epilog counts, and primary handler RVA..xdatarecords cleanly viaerrorwithout crashing."unwind"breakdown tocensus()JSON output and an## Unwind (.xdata) detailssection toto_markdown()while keeping all existing JSON keys and Markdown headings backwards-compatible.tests/test_recomp_census_unwind.py(17 unit tests using synthetic byte-built PE32+ fixtures, no game data).main(), the file docstring, andtests/test_recomp_census.pyuntouched so this merges cleanly with open PR recomp_census: a wrong input is one ERROR line, not a traceback (RECOMP-CENSUS-WRONG-INPUT) #1088 (RECOMP-CENSUS-WRONG-INPUT).Item ID
RECOMP-CENSUS-XDATA-UNWINDVerification
Tested on macOS 27.2.1 (Apple M5 arm64), Python 3.14 (no game files, no GPU, standard library only):
python3 -I tests/test_recomp_census.py -v-> 7/7 OKpython3 -I tests/test_recomp_census_unwind.py -v-> 17/17 OKtools/recomp_census.pytoupstream/mainwhile keepingtests/test_recomp_census_unwind.py) -> FAILED (3 failures, 23 errors), directly provingFHANDLER != CHAINED,12 != 0(SizeOfPrologvsCountOfCodes), and0x8falsely flagged asCHAINEDonmain.RECOMP-CENSUS-WRONG-INPUT): auto-merged with 0 conflicts, running 11/11test_recomp_census.py+ 17/17test_recomp_census_unwind.py(28/28 OK).python3 -m compileall -q tools/recomp_census.py tests/test_recomp_census.py tests/test_recomp_census_unwind.py-> OKpython3 -I scripts/check_no_game_data.py tools/recomp_census.py tests/test_recomp_census_unwind.py-> OKpython3 -I tests/test_ci_registration.py-> 15/15 OK (new test file selected by CI stdlib loop)python3 -I tests/test_text_write_line_endings.py-> 3/3 OKChecklist