diff options
| author | kett1m <benho0@proton.me> | 2026-11-24 19:35:16 +0100 |
|---|---|---|
| committer | kett1m <benho0@proton.me> | 2026-11-24 19:35:16 +0100 |
| commit | 84239b50b2af3e040a911727583de8edac260469 (patch) | |
| tree | 9c98490bc1bd01f79a3a5f88d34a5306f9a9048d /runtime/test/cpp_unwind_test.cpp | |
| parent | 7b78bd6637a1d958e707669c24e1caf88558affc (diff) | |
x64_recomp: a buffer that ends inside a VEX/EVEX prefix is a DecodeError (X64-RECOMP-VEX-BOUNDS)
`decode_one`'s docstring promises it never reads past `end`, but the VEX/EVEX prefix path
broke that promise in three places: the three-byte VEX form read `buf[pos+2]` behind a
`pos + 1 < end` guard, and the two VEX forms and EVEX read the opcode that follows the
prefix at `buf[pos]` after advancing `pos` past `end`, unchecked. A buffer that ends inside
a prefix raised `IndexError`, which `disasm()` does not catch (it catches `DecodeError`
only), so the walk died: the retail image (`game_scarlett_master.exe`, SHA-256
e95020b2fa4a721db3df59fdecf75621730ac559d8835252f6c3b658d5a08993) aborted
`tools/recomp_census.py` with `IndexError: index out of range` at `tools/x64_recomp.py`
line 532, reached through the vzeroupper desync fixed in the previous commit.
The fix raises `DecodeError` where the prefix loop and the REX path already do, so a cut
prefix is a reported gap rather than a crash. Tests: `test_truncated_vex_and_evex_are_decode_errors`
covers the four prefix shapes at the end of a buffer; `test_never_reads_past_end` decodes
every sequence of one to four bytes over a 28-byte alphabet of prefixes, REX bytes, escape
bytes and opcodes (637,420 sequences) and requires each to stay inside the buffer or raise
`DecodeError`. Both fail against the unfixed decoder (`IndexError: index out of range` on
`c462`, and the four shapes). A census-level test
(`test_truncated_vex_prefix_is_a_gap_not_a_crash`) shows a `.pdata` function cut inside a
prefix is now reported as a decode gap.
With the vzeroupper fix in, no `.pdata` function of the retail image reaches this path any
more (0 of 299,257); the report of `tools/recomp_census.py` is unchanged by this commit. The
bound is what keeps a buffer a caller really cut, at a `.pdata` or disassembly boundary,
from killing the caller. Tests are synthetic; no game files.
Hardware: AMD Ryzen 5 7600X, Linux 7.3.4-1-default, Python 3.13.18; CPU-only, no GPU.
AI-assisted (DeepSeek V4.1 Flash).
Diffstat (limited to 'runtime/test/cpp_unwind_test.cpp')
0 files changed, 0 insertions, 0 deletions