tools: preserve concurrent breakpoint hits in debug_launch #1951

Closed
github-bot wants to merge 7 commits from gh-pr/1951/head into gh-pr/1951/base
Owner

@⁠tedin7 on GitHub · 2026-11-24 22:04 UTC · original
tedin7:x2w-frontier-1281-launcher → main · +206 −6 · 4 files · 7 commits · closed without merging

Part of #1281

What this unblocks: the launcher keeps concurrent hits on a hooked function, so file tracing, the offline socket deny and the -MapDrive rewrite no longer miss overlapping calls.

Verification:

  • python3 -I tests/startup_debug_launch_concurrent_check.py -> Ran 3 tests, OK (Linux worker).
  • With the suspend step disabled the same test fails (1 failure), so it guards the fix.
  • python3 -I -m py_compile tools/startup/debug_launch.py tools/startup/step_gate.py -> ok.
  • Not run: hooked launch / startup_map_drive_overlap on Win2025 (no Windows host on this worker). Please run before merge.

Change: new tools/startup/step_gate.py suspends 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.

**@⁠tedin7** on GitHub · 2026-11-24 22:04 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/1951) `tedin7:x2w-frontier-1281-launcher` → `main` · +206 −6 · 4 files · 7 commits · closed without merging Part of #1281 What this unblocks: the launcher keeps concurrent hits on a hooked function, so file tracing, the offline socket deny and the `-MapDrive` rewrite no longer miss overlapping calls. Verification: - `python3 -I tests/startup_debug_launch_concurrent_check.py` -> Ran 3 tests, OK (Linux worker). - With the suspend step disabled the same test fails (1 failure), so it guards the fix. - `python3 -I -m py_compile tools/startup/debug_launch.py tools/startup/step_gate.py` -> ok. - Not run: hooked launch / `startup_map_drive_overlap` on Win2025 (no Windows host on this worker). Please run before merge. Change: new `tools/startup/step_gate.py` suspends 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.
The startup launcher restored the patched byte for a single step, so a second thread entering the
same function in that window was never traced. Other threads are now suspended for the step, the
byte is patched again only after the last stepper finishes, and overlapping hits are counted in the log.
# Conflicts:
#	.github/workflows/windows.yml
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 23:44:51 +00:00
github-bot closed this pull request 2026-11-26 23:44:51 +00:00
Author
Owner

@⁠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.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-26T10:42:10.132560Z
We couldn’t complete this review. Comment @codex review to try again.
ff733ed Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@⁠codex review" or "@⁠codex security review".

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:05 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/1951#issuecomment-7145779506) · edited 2026-11-26 10:42 UTC <!-- codex-pull-request-review-summary --> <!-- codex-review-state:v1 {"code_review":{"commit_sha":"ff733ed34e332e3ce83279051b586ac454fe484c","has_any_findings":true,"has_unresolved_findings":true,"status":"failed"},"security_review":{"commit_sha":null,"has_any_findings":null,"has_unresolved_findings":null,"status":null}} --> <details> <summary><strong>Codex Review Summary</strong>: ❌ Failed</summary> This comment shows the latest Codex review activity on this pull request. | Review | Status | Commit | Review trigger | | --- | --- | --- | --- | | 📝 **Code Review** | ❌ **Failed** <relative-time datetime="2026-11-26T10:42:10.132560Z">2026-11-26T10:42:10.132560Z</relative-time><br/>We couldn’t complete this review. Comment `@codex review` to try again. | `ff733ed` | Draft marked ready | <details> <summary>ℹ️ About Codex in GitHub</summary> <br/> [Your team has set up Codex to review pull requests in this repo](https://chatgpt.com/codex/cloud/settings/general). Reviews are triggered when you - Open a pull request for review - Mark a draft as ready - Comment "@⁠codex review" or "@⁠codex security review". Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. </details> </details>
Author
Owner

@⁠chatgpt-codex-connector[bot] on GitHub · 2026-11-24 22:10 UTC · original

P1 Badge Release gate-owned suspensions before a queued hit steps

In the queued-hit case modeled by test_byte_stays_open_until_the_last_stepper_finishes, begin(1, addr) suspends thread 2, but begin(2, addr) never releases that gate-owned suspend count before marking it as stepping. ContinueDebugEvent does not cancel SuspendThread, so thread 2 cannot produce its single-step event, while finish(1) will not release the holds because thread 2 remains in stepping. 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 allowing end(2) on a suspended thread.

Useful? React with 👍 / 👎.

**@⁠chatgpt-codex-connector[bot]** on GitHub · 2026-11-24 22:10 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/1951#discussion_r4687231362) **<sub><sub>![P1 Badge](https://img.shields.io/badge/P1-orange?style=flat)</sub></sub> Release gate-owned suspensions before a queued hit steps** In the queued-hit case modeled by `test_byte_stays_open_until_the_last_stepper_finishes`, `begin(1, addr)` suspends thread 2, but `begin(2, addr)` never releases that gate-owned suspend count before marking it as stepping. `ContinueDebugEvent` does not cancel `SuspendThread`, so thread 2 cannot produce its single-step event, while `finish(1)` will not release the holds because thread 2 remains in `stepping`. 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 allowing `end(2)` on a suspended thread. Useful? React with 👍 / 👎. <!-- codex-code-review-finding:v1 -->
Author
Owner

@⁠chatgpt-codex-connector[bot] on GitHub · 2026-11-24 22:10 UTC · original

P2 Badge Release held threads when the last stepper exits

If the last stepping thread exits before delivering its single-step event—for example, through asynchronous termination—the launcher's EXIT_THREAD handler calls forget(), which empties stepping but leaves the other threads suspended in _held. Only finish() 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 👍 / 👎.

**@⁠chatgpt-codex-connector[bot]** on GitHub · 2026-11-24 22:10 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/1951#discussion_r4687231371) **<sub><sub>![P2 Badge](https://img.shields.io/badge/P2-yellow?style=flat)</sub></sub> Release held threads when the last stepper exits** If the last stepping thread exits before delivering its single-step event—for example, through asynchronous termination—the launcher's `EXIT_THREAD` handler calls `forget()`, which empties `stepping` but leaves the other threads suspended in `_held`. Only `finish()` 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 👍 / 👎. <!-- codex-code-review-finding:v1 -->
Author
Owner

@⁠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:

out/pe-env/Scripts/python.exe -I tests/startup_debug_launch_concurrent_check.py
Ran 3 tests in 0.000s
OK      exit 0

Mutations to tools/startup/step_gate.py, each reverted:

mutation result
for other in sorted(self._live()) → for other in [] (suspend nothing) caught
return None if addr in self.stepping.values() else addr → return addr (repatch while another thread steps) caught
overlap = addr in self.stepping.values() → False caught
if not self.stepping: → if True: (resume held threads while another thread still steps) not caught

Why the survivor matters, with the trace

Driving the gate directly with two threads stepping the same address:

begin 1 at A -> overlap False
begin 2 at A -> overlap True
  suspends: [('suspend',2), ('suspend',3), ('suspend',4), ('suspend',3), ('suspend',4)]
finish 1 -> None                      # still open, thread 2 is stepping it
  resumes while thread 2 still steps A: []        # correct

same run with `if True:`:
finish 1 -> None
  resumes while thread 2 still steps A: [('resume',2), ('resume',3), ('resume',3), ('resume',4), ('resume',4)]

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 dropped and checks the
address returned by finish, so both overlap and the repatch rule are pinned, but nothing asserts that no resume happens
before the last stepper finishes
.

Suggested assertion, in the same style

def test_no_thread_is_resumed_while_another_still_steps(self):
    resumed = []
    gate = StepGate(lambda tid: True, resumed.append, lambda: [1, 2, 3])
    gate.begin(1, 0xA0)
    gate.begin(2, 0xA0)
    resumed.clear()
    self.assertIsNone(gate.finish(1))
    self.assertEqual(resumed, [])                     # the whole point of the gate
    self.assertEqual(gate.finish(2), 0xA0)
    self.assertTrue(resumed)                          # and they do come back afterwards

The second half matters too: a gate that never resumes would pass the first assertion alone.

What the rest of the design gets right

  • _held is a count per thread, not a flag, so a thread suspended by two overlapping begin calls is resumed twice — the
    trace above shows suspend 3 and suspend 4 twice each.
  • forget(tid) drops both maps, so a thread that exits mid-step cannot be resumed later or block the repatch forever.
  • begin skips threads that are already stepping (other not in self.stepping), which is what keeps two steppers from
    suspending 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 the
pure-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

  • AI-assisted review.
**@⁠ChazY11** on GitHub · 2026-11-24 22:11 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/1951#issuecomment-7145910180) ## Ran it, and found the one place the gate's guarantee is unasserted Windows 11 build 26300.9974: ```powershell out/pe-env/Scripts/python.exe -I tests/startup_debug_launch_concurrent_check.py Ran 3 tests in 0.000s OK exit 0 ``` Mutations to `tools/startup/step_gate.py`, each reverted: | mutation | result | |---|---| | `for other in sorted(self._live())` → `for other in []` (suspend nothing) | **caught** | | `return None if addr in self.stepping.values() else addr` → `return addr` (repatch while another thread steps) | **caught** | | `overlap = addr in self.stepping.values()` → `False` | **caught** | | **`if not self.stepping:` → `if True:` (resume held threads while another thread still steps)** | **not caught** | ## Why the survivor matters, with the trace Driving the gate directly with two threads stepping the same address: ```text begin 1 at A -> overlap False begin 2 at A -> overlap True suspends: [('suspend',2), ('suspend',3), ('suspend',4), ('suspend',3), ('suspend',4)] finish 1 -> None # still open, thread 2 is stepping it resumes while thread 2 still steps A: [] # correct same run with `if True:`: finish 1 -> None resumes while thread 2 still steps A: [('resume',2), ('resume',3), ('resume',3), ('resume',4), ('resume',4)] ``` 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 `dropped` and checks the address returned by `finish`, so both `overlap` and the repatch rule are pinned, but nothing asserts **that no resume happens before the last stepper finishes**. ## Suggested assertion, in the same style ```python def test_no_thread_is_resumed_while_another_still_steps(self): resumed = [] gate = StepGate(lambda tid: True, resumed.append, lambda: [1, 2, 3]) gate.begin(1, 0xA0) gate.begin(2, 0xA0) resumed.clear() self.assertIsNone(gate.finish(1)) self.assertEqual(resumed, []) # the whole point of the gate self.assertEqual(gate.finish(2), 0xA0) self.assertTrue(resumed) # and they do come back afterwards ``` The second half matters too: a gate that never resumes would pass the first assertion alone. ## What the rest of the design gets right - `_held` is a *count* per thread, not a flag, so a thread suspended by two overlapping `begin` calls is resumed twice — the trace above shows `suspend 3` and `suspend 4` twice each. - `forget(tid)` drops both maps, so a thread that exits mid-step cannot be resumed later or block the repatch forever. - `begin` skips threads that are already stepping (`other not in self.stepping`), which is what keeps two steppers from suspending 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 the pure-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 - AI-assisted review.
Author
Owner

@⁠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](https://github.com/R0Y00/Xbox2Windows/pull/1951#discussion_r4688626150) 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
Author
Owner

@⁠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 00:44 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/1951#discussion_r4688626430) 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
Author
Owner

@⁠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_steps in tests/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, OK
  • mutation if not self.stepping: -> if True: in tools/startup/step_gate.py -> the new test fails (1 failure of 6); mutation reverted
  • python3 -B tests/docs_links_check.py -> OK

AI-assisted; commands listed were executed locally.

**@⁠tedin7** on GitHub · 2026-11-25 10:48 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/1951#issuecomment-7160191816) @⁠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_steps` in `tests/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, OK - mutation `if not self.stepping:` -> `if True:` in `tools/startup/step_gate.py` -> the new test fails (1 failure of 6); mutation reverted - `python3 -B tests/docs_links_check.py` -> OK AI-assisted; commands listed were executed locally.
Author
Owner

@⁠tedin7 on GitHub · 2026-11-25 13:47 UTC · original

Thanks, all points addressed in abadcfb3f.

  • All-or-nothing gate: 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 returns None. debug_launch.py calls gate.begin() before it opens the byte, so the byte stays patched and the thread re-executes the breakpoint. Commit abadcfb3f.
  • Roll back held peers: when a later peer cannot be suspended, the peers already taken are resumed and nothing is recorded as held or stepping. Commit abadcfb3f.
  • Deterministic fake: StepGateTest.test_failed_suspension_leaves_the_gate_closed_and_rolls_back in tests/startup_debug_launch_concurrent_check.py uses 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 with python3 -m unittest tests.startup_debug_launch_concurrent_check: 7 tests OK.
  • Win2025 WARP at head abadcfb3 (x2w_pipe.py win2025 1951): startup_host_cpu_debug, startup_run_ps1 and startup_debug pass 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 13:47 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/1951#issuecomment-7164283381) Thanks, all points addressed in abadcfb3f. - All-or-nothing gate: `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 returns `None`. `debug_launch.py` calls `gate.begin()` before it opens the byte, so the byte stays patched and the thread re-executes the breakpoint. Commit abadcfb3f. - Roll back held peers: when a later peer cannot be suspended, the peers already taken are resumed and nothing is recorded as held or stepping. Commit abadcfb3f. - Deterministic fake: `StepGateTest.test_failed_suspension_leaves_the_gate_closed_and_rolls_back` in `tests/startup_debug_launch_concurrent_check.py` uses 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 with `python3 -m unittest tests.startup_debug_launch_concurrent_check`: 7 tests OK. - Win2025 WARP at head abadcfb3 (`x2w_pipe.py win2025 1951`): `startup_host_cpu_debug`, `startup_run_ps1` and `startup_debug` pass 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.
Author
Owner

@⁠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 18:30 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/1951#issuecomment-7170999054) @⁠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.
Author
Owner

@⁠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-25 21:33 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/1951#issuecomment-7175240850) 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.
Author
Owner

@⁠tedin7 on GitHub · 2026-11-26 10:37 UTC · original

Merged origin/main into this branch (no force; one conflict in the windows.yml check list, both lines kept). New head ff733ed34.

Verification:

  • Linux: python3 -B tests/startup_debug_launch_concurrent_check.py -> 7 tests OK.
  • Win2025 (proxmox), dev + release, head 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 checks tests/startup_debug_launch_concurrent_check.py and tests/startup_launch_cli_check.py rc=0.
  • One earlier dev run had startup_launch fail its "fast-fail" timing assertion (process killed at 1.00 s, the limit is < 1.0 s). It does not use debug_launch.py or step_gate.py; the immediate rerun passed twice.

Overlap with #1408: both change the same step-over region of debug_launch.py (the stepping map, 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) and SuspendThread / ResumeThread documentation.

AI-assisted; commands listed were executed locally.

**@⁠tedin7** on GitHub · 2026-11-26 10:37 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/1951#issuecomment-7189615931) Merged `origin/main` into this branch (no force; one conflict in the `windows.yml` check list, both lines kept). New head `ff733ed34`. Verification: - Linux: `python3 -B tests/startup_debug_launch_concurrent_check.py` -> 7 tests OK. - Win2025 (proxmox), dev + release, head `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 checks `tests/startup_debug_launch_concurrent_check.py` and `tests/startup_launch_cli_check.py` rc=0. - One earlier dev run had `startup_launch` fail its "fast-fail" timing assertion (process killed at 1.00 s, the limit is < 1.0 s). It does not use `debug_launch.py` or `step_gate.py`; the immediate rerun passed twice. Overlap with #1408: both change the same step-over region of `debug_launch.py` (the `stepping` map, 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`) and `SuspendThread` / `ResumeThread` documentation. AI-assisted; commands listed were executed locally.
Author
Owner

@⁠tedin7 on GitHub · 2026-11-26 10:42 UTC · original

Independent Stage-2 gate of head ff733ed34: PASS.

Checked:

  • The gate is all-or-nothing: every live peer is suspended before the hooked byte is opened; if one cannot be suspended the byte stays patched and the hit is retried. A thread that exits while stepping re-arms the byte (forget).
  • Real threads, not fakes: the overlap mode of tests/startup_launch_probe.cpp from #1408 (4 threads x 16 rounds, all entering CreateFileW together, 64 opens) run under tools/startup/debug_launch.py --trace-files 1 on Win2025 (proxmox): 3 runs with this PR, each overlap opens 64 of 64 and 64 of 64 successful NtCreateFile lines in files.txt. Control: the same run with step_gate.py replaced by a copy that never holds a peer lost opens on its first run (60 of 64 traced).

Verification (Win2025, proxmox only, head ff733ed34 plus 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.
  • Same regex with the overlap test added: dev 6/6 and release 6/6 passed.
  • 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.

**@⁠tedin7** on GitHub · 2026-11-26 10:42 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/1951#issuecomment-7189716182) Independent Stage-2 gate of head ff733ed34: PASS. Checked: - The gate is all-or-nothing: every live peer is suspended before the hooked byte is opened; if one cannot be suspended the byte stays patched and the hit is retried. A thread that exits while stepping re-arms the byte (`forget`). - Real threads, not fakes: the overlap mode of `tests/startup_launch_probe.cpp` from #1408 (4 threads x 16 rounds, all entering `CreateFileW` together, 64 opens) run under `tools/startup/debug_launch.py --trace-files 1` on Win2025 (proxmox): 3 runs with this PR, each `overlap opens 64 of 64` and 64 of 64 successful `NtCreateFile` lines in `files.txt`. Control: the same run with `step_gate.py` replaced by a copy that never holds a peer lost opens on its first run (60 of 64 traced). Verification (Win2025, proxmox only, head ff733ed34 plus 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. - Same regex with the overlap test added: dev 6/6 and release 6/6 passed. - `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.
Author
Owner

@⁠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.

**@⁠chatgpt-codex-connector[bot]** on GitHub · 2026-11-26 10:42 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/1951#issuecomment-7189720894) You have reached your Codex usage limits for code reviews. You can see your limits in the [Codex usage dashboard](https://chatgpt.com/codex/cloud/settings/usage). To continue using code reviews, add credits to your account and enable them for code reviews in your [settings](https://chatgpt.com/settings/code-review).
Author
Owner

@⁠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:

  • other threads cannot run through the step: StepWindow.open holds every other thread (startup_hook_check.py bookkeeping case);
  • the window closes only when its owner finishes or exits (finish, abandon), and no held thread resumes earlier;
  • a held thread that already hit the hook goes back to the hook address and traps again after the window (defer; this PR's "queued hit runs to step");
  • exited or exiting threads are classified and never resumed (classify_hold, classify_status);
  • one difference by design: this PR refused to open the byte when a peer could not be suspended and retried the hit. #1408 steps and reports the window as unprotected, because a thread that is exiting cannot be suspended and a retry would never end. #1408 also adds a deadline, the --suspend-others 0 control and a real-thread test.

Compared at #1408 head 08f0f4e9f against this PR's head ff733ed34; no case of this PR's startup_debug_launch_concurrent_check.py is missing there.

Source: Microsoft Learn, Win32 debugging API (WaitForDebugEvent, ContinueDebugEvent) and SuspendThread documentation.

AI-assisted; commands listed were executed locally.

**@⁠tedin7** on GitHub · 2026-11-26 10:51 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/1951#issuecomment-7189939929) 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: - other threads cannot run through the step: `StepWindow.open` holds every other thread (`startup_hook_check.py` bookkeeping case); - the window closes only when its owner finishes or exits (`finish`, `abandon`), and no held thread resumes earlier; - a held thread that already hit the hook goes back to the hook address and traps again after the window (`defer`; this PR's "queued hit runs to step"); - exited or exiting threads are classified and never resumed (`classify_hold`, `classify_status`); - one difference by design: this PR refused to open the byte when a peer could not be suspended and retried the hit. #1408 steps and reports the window as unprotected, because a thread that is exiting cannot be suspended and a retry would never end. #1408 also adds a deadline, the `--suspend-others 0` control and a real-thread test. Compared at #1408 head `08f0f4e9f` against this PR's head `ff733ed34`; no case of this PR's `startup_debug_launch_concurrent_check.py` is missing there. Source: Microsoft Learn, Win32 debugging API (`WaitForDebugEvent`, `ContinueDebugEvent`) and `SuspendThread` documentation. AI-assisted; commands listed were executed locally.
Author
Owner

@⁠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

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@⁠codex review".

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".

**@⁠chatgpt-codex-connector[bot]** on GitHub · 2026-11-24 22:10 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/1951#pullrequestreview-6048206490) · **reviewed** <!-- codex-review-receipt:v1 --> ### 💡 Codex Review Here are some automated review suggestions for this pull request. **Reviewed commit:** `aab45db628` <details> <summary>ℹ️ About Codex in GitHub</summary> <br/> [Your team has set up Codex to review pull requests in this repo](https://chatgpt.com/codex/cloud/settings/general). Reviews are triggered when you - Open a pull request for review - Mark a draft as ready - Comment "@⁠codex review". 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". </details>
Author
Owner

@⁠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.

**@⁠R0Y00** on GitHub · 2026-11-25 12:37 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/1951#pullrequestreview-6057715198) · **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

This discussion has been locked. Commenting is limited to contributors.
No description provided.