tooling: keep VALLOC callers when the stack read crosses an uncommitted page #2194
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2202"
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 Jess-Doit on 2026-11-25T04:23:40Z.
startup_debugfails intermittently on a Windows 10 host because the allocation-caller check finds an empty caller list:Cause: the
X2W_VALLOC_MINhook reads 200 qwords (1,600 bytes) from the hooked thread'srsp. Whenrspis within 1,600 bytes of the end of the last committed stack page,ReadProcessMemorycrosses into an uncommitted page and returns nothing. The caller chain then comes out empty. Whether it happens depends on where the stack sits at the hooked call, so it comes and goes.Change: when the full read returns nothing, read again up to the end of
rsp's page. The return addresses closest torspare the ones the hook needs. This is one hunk intools/startup/debug_launch.pyand changes nothing when the full read succeeds.Measured on Windows 10 build 19045, MSVC 19.44,
devpreset:callers:)mainc118f569mainfd457299+4eafbd8c)CI's Windows host passes
main, so this only shows up on some hosts. This came up during review of #2190 and was split out to keep that PR to one behavior.AI-assisted.
🤖 Generated with Claude Code
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T04:28:10Z.
Review: COMMENTED
Review of head
4eafbd8cf910a8caacb47798dcee9ecda439574a(one hunk,tools/startup/debug_launch.py:378-386).Result: no P1, no P2. Two nits.
What I checked
git diff --stat origin/main...HEAD: 1 file, +6/-1.python3 -I tests/docs_links_check.py: self-test passed, 405 links OK.python3 -I tests/bidi_controls_check.py: self-test passed, no bidi controls in 1481 files.git diff --check origin/main...HEAD: clean.python3 -I -m py_compile tools/startup/debug_launch.py: OK.Logic
read()(line 136) returnsb""on failure, neverNone, sostack.ljust(...)at line 386 is safe even if the retry also fails (caller list is then empty, same as before).min(1600, 0x1000 - (rsp & 0xfff))stays inside rsp's page, which is committed (rsp points into it). Whenrspis page-aligned the size is0x1000, which themincaps at 1600. Correct.unpack_from("<200Q")keeps working. Zero words never fall in a module range, so no false callers.Mutation check (Linux model of the read/retry logic, not the Windows hook itself)
win2025(the change is Python tooling for the debug launcher, not gfx2hlsl or C++, and CI Windows already passes). The PR's own 10/10 vs 5/8 measurement on a Windows 10 host is the evidence for the real fix.Nits
read_stack(read, rsp)) would allow a unit test with a fakeread, but this is optional.Cause statement in the PR body matches what the code does. Fine to merge from my side once the maintainers are happy.
AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T04:42:21Z.
Review: COMMENTED
Re-review of head
6948da674ff471983e8ef4a81e94c39a84d1ed1e(previous review covered4eafbd8c).Scope:
tools/startup/debug_launch.py(+10/-1) andtests/startup_debug_check.py(+10/-1). The stack read moves into a smallread_stack(read, rsp, words)helper: try the full read, else read to the end of RSP's page, else zero-fill; always pad to8*words.Commands executed locally (Linux)
git diff --check origin/main...HEAD-> cleanpython3 tests/docs_links_check.py-> self-test passed, 18 files / 405 links OKpython3 tests/bidi_controls_check.py-> self-test passed, 1481 files, no bidi controlsdebug_launch.pyimportsctypes.WinDLL, so it cannot be imported on Linux. I extractedread_stackverbatim and ran the exact new assertions fromstartup_debug_check.py(RSP 0x6000/0x6a00/0x6fe0/0x6ff8 plus the all-fail case): PASS.read_stack, each reverted withgit checkout -- .:0x1000 - (rsp & 0xfff)->0x1000: killed (AssertionError at rsp 0x6a00)ljustzero padding: killed (same assertion)Findings
stack_readmodels only a committed-end boundary. A case with RSP exactly page-aligned at the end (rsp=0x7000, expect all zeros) would pin the "no committed bytes" edge. It is covered in effect by the all-fail case, so optional.The refactor makes the new read path unit-testable. Behavior matches the intent: the words nearest RSP are recovered and the rest is zero-padded. LGTM from a review standpoint (comment only, no approval).
AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by Jess-Doit on 2026-11-25T04:37:38Z.
Thanks for the review and the read/retry model.
6948da67. The read and retry moved intoread_stack(read, rsp, words), and the hook calls it.tests/startup_debug_check.pychecks it with a fakereadwhose committed region ends at0x7000, using your four RSP values. It must recover 1,600, 1,536, 32 and 8 bytes of the right content, zero-pad the rest to 1,600, and return all zeros when both reads fail. With the retry removed, the helper recovers 1,600, 0, 0 and 0 bytes, so those assertions fail. This runs in the Python part ofstartup_debugbefore the probe starts, so it doesn't depend on stack position.ctest --preset dev --no-tests=error -R '^startup_debug$'at6948da67: 5 of 5 passed on the Windows 10 host. The bidi check andgit diff --checkare clean.Status: ready to merge from our side.