Scripts: match record_writers lea length against the stored cursor #1482
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1492"
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 ivall/xcl. Originally posted by microwave805 on 2026-11-24T16:54:18Z.
When a command-writer site in an objdump AT&T listing advances the record cursor via
leainstead ofadd,scripts/re/record_writers.pyignored which register was written back to0x18(%L)and matched anylea 0xN(%reg),%regin the site body. An unrelatedlea(for example off%rsp, or into a different register), or aleawhose destination or base pointer was modified before the store (e.g.add %r8,%rdxafterlea 0x20(%rax),%rdx), silently overwrote the record length or fabricated a length on variable-length sites.What is in it
scripts/re/record_writers.py: capture the destination register%dststored bymov %dst,0x18(%L), match onlylea 0xN(%P),%dstwhen%Pis untouched beforehand and%dst(including its sub-register aliases) is not overwritten before the store, and drop the unusedleaalternation in theaddregex.scripts/test_record_writers.py: add synthetic AT&T listing tests covering unrelatedleainstructions, intervening register and sub-register writes to%dst(add %r8,%rdx,add $0x8,%edx), earlier mutations of%P, and harmless memory stores through%dst(movl $0x1,-0x4(%rdx)).Tested
stable-x86_64-pc-windows-msvc, debug), Python 3.11.3424b819:python -I -m unittest discover -s scripts -p "test_*.py" -v: 17 passed, 0 failed.\scripts\test.ps1(withXCL_DXIL_CACHE=%TEMP%\xcl-test-dxil-cache): 770 passed, 0 failed, 41 ignoredgpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask,gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware(no wave64)Regression run
scripts/re/record_writers.pyandscripts/test_record_writers.py(no runtime or build-input files).Not tested
XboxBvhBuilder.dlldisassembly dump (no console binaries)AI use
leamatching bug inscripts/re/record_writers.py, added the conservative intervening-write guard per review feedback, wrote the unit tests and PR description, and ran the verification commands above.Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-24T18:53:30Z.
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~21 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling; clean on single-threaded rerun — same flake seen on unmodifiedmain.)Thanks!
Imported from ivall/xcl. Originally posted by RavenCurseBurg on 2026-11-26T04:31:28Z.
Tested
933c7957aa1854b59620444423c6d723c8dc8bfaagainst a candidate that also includes #1694 and #1730. I passed 16 synthetic AT&T listings topython -B scripts/re/record_writers.py <listing>on each of three revisions. The cases used two register pairs, immediate and list-field headers, and four ways a writer could update or leave its cursor.The previous combination of #1694/#1730 reported 16 bytes from an unrelated LEA for both a 48-byte record and a variable-length record. The candidate and this PR correctly reported 48 and
Nonerespectively. On the candidate, the in-place 40-byte addition still reported 40, both header forms and fallback slot 9 were preserved, and listings with a return before the cursor write produced zero sites.This head passed its two focused test methods. On the combined candidate,
python -B -m unittest discover -s scripts -p "test_*.py"passed all 20 tests with no skips. Windows build 26100, i7-13700, Python 3.14.3. OpenAI Codex (GPT-6) integrated the changes and ran the checks on text inputs. No binary disassembly, game, GPU or Rust run.Retest of the register-write change on
424b8193c444992e4ac7d45c411fa8519e8fd005I ran six synthetic CLI fixtures for compare-exchange and ordinary comparison. Four reported a 32-byte length on this head when the stored cursor could have changed. They cover a write to a destination subregister, a memory compare-exchange that can update the accumulator, and both double-width forms that can update the high register. The two controls, a read-only source register and an ordinary comparison, correctly kept the length at 32.
Candidate on this exact PR head. All six cases now return the expected length or
None.python -B -m unittest discover -s scripts -p "test_*.py"passed all 18 tests. I also applied the updated register tracking to the existing #1694/#1730 integration branch. All 21 Python tests and the earlier 16 combined CLI cases passed there, including header selection, fallback slot and return-before-store cases.OpenAI Codex (GPT-6) prepared the candidates and ran these text fixtures on the Windows CPU setup above. No game files, binary disassembly, Rust build or GPU execution were used.
Timestamp-register follow-up
I reproduced the two reported RDTSC cases on
424b8193c444. The synthetic listings covered a clobbered base before the LEA and a clobbered result between the LEA and the cursor store. Across nine RDTSC/RDTSCP cases, the upstream script reported 32 bytes in five cases where the length was unknown. The four positive controls retained their valid 32-byte length.The updated candidate accounts for both timestamp output registers and RDTSCP’s additional ECX output. All nine CLI cases and all 19 Python tests passed. The updated combined branch passed all 22 Python tests and its earlier 16 CLI checks. OpenAI Codex (GPT-6) ran the checks with synthetic text on the Windows CPU setup above using
python -B -m unittest discover -s scripts -p "test_*.py". No title, binary disassembly, GPU or Rust tests were run.Imported from ivall/xcl. Originally posted by luckyteagirl on 2026-11-26T05:37:54Z.
Review: COMMENTED
Could this trust a matching LEA only if its destination survives unchanged to the cursor store? In the new synthetic AT&T fixture, inserting
add %r8,%rdxbetweenlea 0x20(%rax),%rdxandmov %rdx,0x18(%rcx)still reportslength 32 B, although the actual cursor advance is32 + r8and therefore variable. A conservative guard for intervening writes to%rdx, plus that fixture, would leave the length unknown. Reproduced with the record-writer script at exact head933c7957aa1854b59620444423c6d723c8dc8bfa; no retail title or GPU run. AI-assisted review with Codex.Imported from ivall/xcl. Originally posted by microwave805 on 2026-11-26T23:44:11Z.
@luckyteagirl Good point — updated
scripts/re/record_writers.py(424b8193c444) to track whether%Pwas mutated beforehand and whether any instruction betweenlea 0xN(%P),%dstandmov %dst,0x18(%L)writes%dst(including sub-register aliases,call,xchg/xadd/cmpxchg, and implicitrax/rdxops while still allowing memory stores through%dstlikemovl $0x1,-0x4(%rdx)). Added synthetic fixtures foradd %r8,%rdx,add $0x8,%edx, pre-lea%Pmutation, and memory stores through%dst.Re-ran
python -I -m unittest discover -s scripts -p "test_*.py" -v(17 passed, 0 failed) and.\scripts\test.ps1(770 passed, 0 failed, 41 ignored, 2SKIPPEDno wave64on RTX 3070) on424b819and updated Tested in the description.(AI use: Antigravity (
Gemini 4 Neon) implemented the guard and tests, ran the suites, and drafted this comment.)Imported from ivall/xcl. Originally posted by JJAutoCompare on 2026-11-27T00:11:21Z.
Tested: Clean
424b8193c444992e4ac7d45c411fa8519e8fd005on Windows 11 build 26200, Ryzen 7 3800X and Python 3.13.7 x64.python.exe -I -B -m unittest discover -s scripts -p test_record_writers.py -v: 2 passed, 0 failed, 0 skipped. A supplementarypython.exe -I -B verify_cursor.pyrun compared 11 synthetic AT&T listing cases through the CLI. Head matched 9 expectations and missed 2. Parentb7aa9f3bd212088e0d927439284dc5ed325ce3c7matched 5 and missed 6. No skips. The candidate corrected thexchg,lock xadd, call, and one-operandmulcases.Both revisions still reported a 32-byte advance instead of an unknown length in two synthetic controls:
rdtscbefore a LEA using RAX as its base, andrdtscafter a LEA writing RDX but before the cursor store. The control using R10 and R9 retained 32 bytes, as expected.Not tested: Rust workspace, GPU, or retail data. Synthetic text fixtures only.
AI use: T3 Code / Codex (
gpt-6.2-sol) wrote the supplementary fixtures, ran and reran the checks, and drafted this report.Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T05:55:10Z.
Triage (#1607) – head
424b819No other PR changes the lea length match in scripts/re/record_writers.py. #2049 restructures the same script (CLI handling) but keeps the old lea logic, so the two will conflict but do not overlap.
No problems found in the diff: the lea is now accepted only when it is based on the cursor register, writes the register stored to 0x18(%L), and neither is clobbered in between; the six synthetic cases cover each rule.
Recommendation: keep open.
AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.