tools: preserve concurrent breakpoint hits in debug_launch #1951
No reviewers
Labels
No labels
accessibility
awaiting author
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
priority: P0
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/R0Y00--Xbox2Windows!1951
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1951/head"
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?
@tedin7 on GitHub · 2026-11-24 22:04 UTC · original
tedin7:x2w-frontier-1281-launcher→main· +206 −6 · 4 files · 7 commits · closed without mergingPart of #1281
What this unblocks: the launcher keeps concurrent hits on a hooked function, so file tracing, the offline socket deny and the
-MapDriverewrite no longer miss overlapping calls.Verification:
python3 -I tests/startup_debug_launch_concurrent_check.py-> Ran 3 tests, OK (Linux worker).python3 -I -m py_compile tools/startup/debug_launch.py tools/startup/step_gate.py-> ok.startup_map_drive_overlapon Win2025 (no Windows host on this worker). Please run before merge.Change: new
tools/startup/step_gate.pysuspends the other live threads while one steps over a restored hook byte, re-patches only after the last stepper finishes, and the launcher logs how many overlapping hits it held.AI-assisted; commands listed were executed locally.
@chatgpt-codex-connector[bot] on GitHub · 2026-11-24 22:05 UTC · original · edited 2026-11-26 10:42 UTC
Codex Review Summary: ❌ Failed
This comment shows the latest Codex review activity on this pull request.
We couldn’t complete this review. Comment
@codex reviewto try again.ff733edℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.
@chatgpt-codex-connector[bot] on GitHub · 2026-11-24 22:10 UTC · original
In the queued-hit case modeled by
test_byte_stays_open_until_the_last_stepper_finishes,begin(1, addr)suspends thread 2, butbegin(2, addr)never releases that gate-owned suspend count before marking it as stepping.ContinueDebugEventdoes not cancelSuspendThread, so thread 2 cannot produce its single-step event, whilefinish(1)will not release the holds because thread 2 remains instepping. This can stall an overlapping-call launch until timeout. Release the entering stepper's gate-owned suspensions; the current fake test hides the problem by allowingend(2)on a suspended thread.Useful? React with 👍 / 👎.
@chatgpt-codex-connector[bot] on GitHub · 2026-11-24 22:10 UTC · original
If the last stepping thread exits before delivering its single-step event—for example, through asynchronous termination—the launcher's
EXIT_THREADhandler callsforget(), which emptiessteppingbut leaves the other threads suspended in_held. Onlyfinish()releases those suspensions, and no remaining stepper can now reach it, so the surviving workers remain frozen until the launcher times out. Forgetting the last stepper needs to unwind the outstanding gate-owned suspensions, not just remove its dictionary entries.Useful? React with 👍 / 👎.
@ChazY11 on GitHub · 2026-11-24 22:11 UTC · original
Ran it, and found the one place the gate's guarantee is unasserted
Windows 11 build 26300.9974:
Mutations to
tools/startup/step_gate.py, each reverted:for other in sorted(self._live())→for other in [](suspend nothing)return None if addr in self.stepping.values() else addr→return addr(repatch while another thread steps)overlap = addr in self.stepping.values()→Falseif not self.stepping:→if True:(resume held threads while another thread still steps)Why the survivor matters, with the trace
Driving the gate directly with two threads stepping the same address:
The mutated gate releases every suspended thread the moment the first stepper finishes, while the second is still stepping over
the restored original byte — exactly the window the module docstring says it closes. The fixture counts
droppedand checks theaddress returned by
finish, so bothoverlapand the repatch rule are pinned, but nothing asserts that no resume happensbefore the last stepper finishes.
Suggested assertion, in the same style
The second half matters too: a gate that never resumes would pass the first assertion alone.
What the rest of the design gets right
_heldis a count per thread, not a flag, so a thread suspended by two overlappingbegincalls is resumed twice — thetrace above shows
suspend 3andsuspend 4twice each.forget(tid)drops both maps, so a thread that exits mid-step cannot be resumed later or block the repatch forever.beginskips threads that are already stepping (other not in self.stepping), which is what keeps two steppers fromsuspending each other into a deadlock.
Scope
The Windows half (hooked launch,
startup_map_drive_overlap) I cannot run here; the PR already says so. Everything above is thepure-Python gate, which is where the concurrency rule lives.
Verdict
Reviewed. Four rules, three pinned; the missing one is the gate's own guarantee.
Notes
@tedin7 on GitHub · 2026-11-25 00:44 UTC · original
Fixed in f8dd917b: begin() now releases the gate-owned suspend count of a thread before it steps (test_queued_hit_runs_to_step). AI-assisted; commands listed were executed locally: python3 -I tests/startup_debug_launch_concurrent_check.py
@tedin7 on GitHub · 2026-11-25 00:44 UTC · original
Fixed in f8dd917b: forget() now unwinds like finish(), releasing held threads and returning the address to re-patch when the last stepper exits (test_last_stepper_exit_releases_held_threads). AI-assisted; commands listed were executed locally: python3 -I tests/startup_debug_launch_concurrent_check.py
@tedin7 on GitHub · 2026-11-25 10:48 UTC · original
@ChazY11 thank you, the survivor mutation was a real gap in the gate's own guarantee.
Added in
b559ad51:test_no_thread_is_resumed_while_another_still_stepsintests/startup_debug_launch_concurrent_check.py. It checks that held threads stay suspended after the first stepper finishes, and that all of them are released after the last one.Commands executed locally:
python3 -B tests/startup_debug_launch_concurrent_check.py-> Ran 6 tests, OKif not self.stepping:->if True:intools/startup/step_gate.py-> the new test fails (1 failure of 6); mutation revertedpython3 -B tests/docs_links_check.py-> OKAI-assisted; commands listed were executed locally.
@tedin7 on GitHub · 2026-11-25 13:47 UTC · original
Thanks, all points addressed in
abadcfb3f.StepGate.begin()now suspends every live peer first and only then marks the thread as stepping (tools/startup/step_gate.py). On a failed suspension it returnsNone.debug_launch.pycallsgate.begin()before it opens the byte, so the byte stays patched and the thread re-executes the breakpoint. Commitabadcfb3f.abadcfb3f.StepGateTest.test_failed_suspension_leaves_the_gate_closed_and_rolls_backintests/startup_debug_launch_concurrent_check.pyuses four live IDs with peer 4 refusing suspension. It checks no stepping,dropped == 0, and 2 and 3 released. It then retries successfully and checks cleanup. Run withpython3 -m unittest tests.startup_debug_launch_concurrent_check: 7 tests OK.abadcfb3(x2w_pipe.py win2025 1951):startup_host_cpu_debug,startup_run_ps1andstartup_debugpass in dev and release (3/3 each). These targets do not start two real overlapping launches with a source-built child; that case is covered only by the deterministic fake above.AI-assisted; commands listed were executed locally.
@tedin7 on GitHub · 2026-11-25 18:30 UTC · original
@R0Y00 the changes you requested are addressed on the current head
abadcfb3f0848b78d6940dcf4dddd2dd91b3799d(see our reply above). Could you re-review, or dismiss the change request if it is resolved? Under the new scope, MasterDomino can then review and merge it.AI-assisted; commands listed were executed locally.
@tedin7 on GitHub · 2026-11-25 21:33 UTC · original
Closing this PR for now so we can focus on the test-speed work. The branch stays as it is, and review comments here remain valid.
We will reopen it later, bring it up to date with
main, re-run the Win2025 WARP checks at its head, and post the result here.AI-assisted; commands listed were executed locally.
@tedin7 on GitHub · 2026-11-26 10:37 UTC · original
Merged
origin/maininto this branch (no force; one conflict in thewindows.ymlcheck list, both lines kept). New headff733ed34.Verification:
python3 -B tests/startup_debug_launch_concurrent_check.py-> 7 tests OK.ff733ed34:x2w_pipe.py win2025 1951 --force --regex '^startup_(debug|launch)'-> 5/5 passed in both builds (startup_debug,startup_debug_log,startup_debug_hooks,startup_launch,startup_launch_cli_check); python checkstests/startup_debug_launch_concurrent_check.pyandtests/startup_launch_cli_check.pyrc=0.startup_launchfail its "fast-fail" timing assertion (process killed at 1.00 s, the limit is < 1.0 s). It does not usedebug_launch.pyorstep_gate.py; the immediate rerun passed twice.Overlap with #1408: both change the same step-over region of
debug_launch.py(thesteppingmap, thread exit, thread suspension). Proposed order is #1408 first, then this PR keeps only what #1408 does not already do (the concurrent check, the all-or-nothing retry when a peer cannot be suspended), or is closed as superseded if nothing is left.Source: Microsoft Learn, Win32 debugging API (
WaitForDebugEvent,ContinueDebugEvent) andSuspendThread/ResumeThreaddocumentation.AI-assisted; commands listed were executed locally.
@tedin7 on GitHub · 2026-11-26 10:42 UTC · original
Independent Stage-2 gate of head
ff733ed34: PASS.Checked:
forget).tests/startup_launch_probe.cppfrom #1408 (4 threads x 16 rounds, all enteringCreateFileWtogether, 64 opens) run undertools/startup/debug_launch.py --trace-files 1on Win2025 (proxmox): 3 runs with this PR, eachoverlap opens 64 of 64and 64 of 64 successfulNtCreateFilelines infiles.txt. Control: the same run withstep_gate.pyreplaced by a copy that never holds a peer lost opens on its first run (60 of 64 traced).Verification (Win2025, proxmox only, head
ff733ed34plus that overlap run registered as an extra CTest):x2w_pipe.py win2025 1951 --force --regex '^startup_(debug|launch)'(c1's run): 5/5 passed in dev and release.python3 -B tests/startup_debug_launch_concurrent_check.py: pass on Linux.Not covered by this PR's own tests: the real-thread overlap above is not in the PR (its test uses fake threads); #1408 has the real-thread test, so whichever of the two merges first should keep that fixture (the two PRs rewrite the same step-over region of
debug_launch.py).AI-assisted; commands listed were executed locally.
@chatgpt-codex-connector[bot] on GitHub · 2026-11-26 10:42 UTC · original
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.
@tedin7 on GitHub · 2026-11-26 10:51 UTC · original
Closing as superseded by #1408, which fixes the same problem (concurrent hook hits while a hook steps over its byte, #1281) and covers every case this PR's check covers:
StepWindow.openholds every other thread (startup_hook_check.pybookkeeping case);finish,abandon), and no held thread resumes earlier;defer; this PR's "queued hit runs to step");classify_hold,classify_status);--suspend-others 0control and a real-thread test.Compared at #1408 head
08f0f4e9fagainst this PR's headff733ed34; no case of this PR'sstartup_debug_launch_concurrent_check.pyis missing there.Source: Microsoft Learn, Win32 debugging API (
WaitForDebugEvent,ContinueDebugEvent) andSuspendThreaddocumentation.AI-assisted; commands listed were executed locally.
@chatgpt-codex-connector[bot] on GitHub · 2026-11-24 22:10 UTC · original · reviewed
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit:
aab45db628ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
@R0Y00 on GitHub · 2026-11-25 12:37 UTC · original · requested changes
The exact Python suite passes, but
StepGate.begin()still enters the stepping state when suspension of a known live peer fails. I reproduced this with two live IDs and a suspend callback returning false. The original byte is already restored by the time the caller enters the gate, and the caller then continues the debug event. That retains the trace gap this PR is meant to eliminate. Please make gate acquisition all-or-nothing before opening the byte, roll back successfully held peers when another suspension fails, and cover the failure with a deterministic fake. Also verify the real overlapping launch on Windows with a source-built child, including both simultaneous calls observed and cleanup.Pull request closed