Repository navigation
tooling: stop at a chosen assert, dump threads mid-run and log large allocations in the startup debugger - #1299
Merged
R0Y00 merged 5 commits intoNov 24, 2026
Conversation
…allocations in the startup debugger X2W_STOP_AT stops at a main-image breakpoint at a given address while --continue-asserts steps over the others and writes threads_stop.txt. X2W_DUMP_AT writes every thread's stack at given times during the run. X2W_VALLOC_MIN logs virtual-memory allocations of at least a given size with the main-image and stand-in callers found on the stack. tests/startup_debug_check.py runs the debugger on a source-built probe that hits two breakpoints, reserves 256 MiB and waits.
tedin7
reviewed
Nov 24, 2026
tedin7
left a comment
Collaborator
There was a problem hiding this comment.
Dual-platform review at commit 8cccacdf737f000c4d2bd4d53860c0a66cb7bd95:
Verification
- Linux:
git diff --check origin/main...HEAD: clean (exit 0)/root/.local/share/x2w-rev-venv/bin/python -B tests/docs_links_check.py: passed (16 Markdown files, 286 links)/root/.local/share/x2w-rev-venv/bin/python -B tests/bidi_controls_check.py: passed (1081 tracked files)
- Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP):
- Debug (
--preset dev):cmake --build --preset dev --target startup_debug_probe -- -j 6(3.61s)ctest --preset dev -R '^startup_debug$' --parallel 4 --no-tests=error --output-on-failure: 1/1 passed (15.74s:startup_debug15.68s)
- Release
/O2(--preset release):cmake --build --preset release --target startup_debug_probe -- -j 6(0.98s)ctest --preset release -R '^startup_debug$' --parallel 4 --no-tests=error --output-on-failure: 1/1 passed (15.72s:startup_debug15.66s)
- Debug (
Code Review Notes
tools/startup/debug_launch.py:NtAllocateVirtualMemory/NtAllocateVirtualMemoryExregister/stack argument decoding (Rdx->&base,R9/R8->&size,[rsp+0x28]/R9->type,[rsp+0x30]/[rsp+0x28]->protect) matches the x64 Windows syscall ABI.X2W_STOP_AT,X2W_DUMP_AT, andX2W_VALLOC_MINare cleanly integrated withtests/startup_debug_check.pycovering positive and negative controls (non-matching RVA, no--continue-asserts, and higherX2W_VALLOC_MINthreshold).- Minor edge cases (non-blocking):
int(os.environ.get("X2W_VALLOC_MIN", "0"), 16)will raiseValueErrorifX2W_VALLOC_MIN=""is set in the environment (or "0"would guard against an empty string).baseinVALLOClogs the input*BaseAddressat syscall entry (which is0x0forVirtualAlloc(nullptr, ...)), rather than the returned allocation base.
…s requested Review: an empty value raised ValueError, and the address logged at entry is the one the caller asked for, not the one returned.
…ger-stop-dump-valloc
tedin7
reviewed
Nov 24, 2026
tedin7
left a comment
Collaborator
There was a problem hiding this comment.
Retest & dual-platform review at commit c0aed1de4dc128b55007e32117b218fb8a223a05 (since 8cccacdf):
Checks
- Linux:
git diff --check origin/main...HEAD: passedtests/docs_links_check.py: passed (16 Markdown files, 290 links)tests/bidi_controls_check.py: passed (1095 tracked files)
- Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP):
- Debug (
--preset dev):cmake --build --preset dev --target startup_debug_probe -- -j 6(2.75s),ctest --preset dev -R '^startup_debug$' --parallel 4 --no-tests=error --output-on-failure: 1/1 passed (18.77s) - Release
/O2(--preset release):cmake --build --preset release --target startup_debug_probe -- -j 6(0.25s),ctest --preset release -R '^startup_debug$' --parallel 4 --no-tests=error --output-on-failure: 1/1 passed (18.74s)
- Debug (
Verification of Prior Notes (8cccacdf)
- Empty
X2W_VALLOC_MIN=""guard (tools/startup/debug_launch.py): Fixed —int(os.environ.get("X2W_VALLOC_MIN") or "0", 16)handles empty strings cleanly, andtests/startup_debug_check.pynow includes an explicitvalloc-emptycontrol. - Entry-point address field naming (
tools/startup/debug_launch.py,docs/startup-runtime.md): Fixed — renamed torequested=and documented as the requested address on syscall entry.
No remaining issues found.
R0Y00
approved these changes
Nov 24, 2026
R0Y00
left a comment
Owner
There was a problem hiding this comment.
Retested the updated launcher on Windows x64 using the source-built startup debug probe. The diagnostic and five controls pass, the short pointer fixture covers all incomplete widths, and the host CPU regression passes with 112 native SHA results. The documentation check resolved 313 links.
R0Y00
enabled auto-merge
November 24, 2026 10:15
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs #870.
Problem
When a startup run under
tools/startup/debug_launch.pygoes wrong some time before it stops, the stop report describes the last fault, not the cause. Three questions kept coming up and had no switch:-ContinueAssertssteps over every main-image breakpoint, so the run only stops later, at the fault the assert led to.Change
Three environment switches, all off by default, read by
debug_launch.py:X2W_STOP_AT=<rva>[,...]--continue-assertswould step over it, and write every thread's stack tothreads_stop.txt.X2W_DUMP_AT=<seconds>[,...]threads_<seconds>.txtat those times.X2W_VALLOC_MIN=<hex bytes>NtAllocateVirtualMemory/NtAllocateVirtualMemoryExcall of at least that size tofiles.txtasVALLOC, with base, size, type, protection and the main-image and stand-in return addresses found on the caller's stack. Needs the file hooks (on by default with--offline 1).They reuse what the debugger already has:
dump_threads, the breakpoint hooks on ntdll and the existing caller scan. Nothing changes when they are unset.Evidence
Commit under test: the head of this branch, on
mainat93cb6a2a.New
tests/startup_debug_check.py, registered asstartup_debug, runs the debugger on a new source-built probe (tests/startup_debug_probe.cpp: two__debugbreak()sites in its own image, a 256 MiBMEM_RESERVE, a 3 s wait, exit 0):What it requires:
--continue-asserts 10: both sites are stepped over, exit code 0, nothreads_stop.txt, noVALLOCline. The two site addresses are read fromevents.txt, not hard-coded.X2W_STOP_AT=<second site>: the first site is still stepped over, the run stops at the second (first chance), andthreads_stop.txtnames the probe image.--continue-assertsthe run stops at the first site as before.X2W_DUMP_AT=1:threads_1.txtexists and holds stacks; the baseline has none.X2W_VALLOC_MIN=10000000: exactly one line withsize=0x10000000andtype=0x2000, and a caller in the probe image. Control:X2W_VALLOC_MIN=20000000logs nothing.Run on: CPython 3.12 for Windows under Wine 11.0 (Proton Experimental) on a Linux host, with the probe built by clang-cl against the Windows SDK. That is a translation-layer result, not Windows.
Also ran
python -B tests/docs_links_check.py(pass) andgit diff --check(clean).In use: these three switches are what located the cause behind #1290 (the first failing assert and its stack, then the one fixed-size block the executable reserves at start-up and who reserved it).
Not measured
VirtualAllocof 256 MiB reachesNtAllocateVirtualMemorywith that exact size, which holds under Wine.X2W_VALLOC_MINon a long run (every allocation call is a debugger round trip) is not measured; it is meant for short diagnostic runs.Overlap
#1274, #1251, #1280 and #1229 also touch
debug_launch.py, in other places. Whichever lands later will need a small rebase.