tools: preserve concurrent breakpoint hits in debug_launch #1944

Closed
tedin7 wants to merge 7 commits from upstream-pr/1951 into main
tedin7 commented 2026-11-24 22:04:44 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T22:04:44Z.


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6592326976 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1951). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T22:04:44Z. --- 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.
chatgpt-codex-connector[bot commented 2026-11-24 23:03:13 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T22:10:32Z.

Review: COMMENTED


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

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6048206490 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1951#pullrequestreview-6048206490). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-24T22:10:32Z. **Review:** COMMENTED --- <!-- 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>
chatgpt-codex-connector[bot commented 2026-11-24 23:03:37 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T22:05:01Z.


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7145779506 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1951#issuecomment-7145779506). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-24T22:05:01Z. --- <!-- 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>
ChazY11 commented 2026-11-24 23:03:37 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by ChazY11 on 2026-11-24T22:11:00Z.


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.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7145910180 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1951#issuecomment-7145910180). Originally posted by [ChazY11](https://github.com/ChazY11) on 2026-11-24T22:11:00Z. --- ## 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.
chatgpt-codex-connector[bot commented 2026-11-24 23:03:44 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T22:10:32Z.

Code review location: tools/startup/step_gate.py; line 27

@@ -0,0 +1,45 @@
+"""Keeps concurrent threads from running through a hooked byte while it is restored for a single step.
+
+A function-entry hook is one patched byte. The thread that hits it restores the original byte, steps one
+instruction, then patches the byte again. Without a gate, every other thread entering the same function in
+that window runs the original byte and its call is never traced. The gate suspends the other threads for
+the step and patches the byte again only once no thread is still stepping over it.
+"""
+
+
+class StepGate:
+    def __init__(self, suspend, resume, live):
+        self._suspend = suspend  # tid -> bool, True when the thread is now suspended
+        self._resume = resume  # tid -> None
+        self._live = live  # callable returning the live thread ids
+        self.stepping = {}  # tid -> address being stepped over
+        self._held = {}  # tid -> suspend count held by the gate
+        self.dropped = 0  # steps begun while another thread was already stepping the same address
+
+    def begin(self, tid, addr):
+        """A thread hit the hook at addr and is about to step. Returns True when addr was already open."""
+        overlap = addr in self.stepping.values()
+        if overlap:
+            self.dropped += 1
+        self.stepping[tid] = addr
+        for other in sorted(self._live()):
+            if other not in self.stepping and self._suspend(other):
+                self._held[other] = self._held.get(other, 0) + 1

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 👍 / 👎.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4687231362 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1951#discussion_r4687231362). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-24T22:10:32Z. **Code review location:** `tools/startup/step_gate.py`; line 27 ~~~~diff @@ -0,0 +1,45 @@ +"""Keeps concurrent threads from running through a hooked byte while it is restored for a single step. + +A function-entry hook is one patched byte. The thread that hits it restores the original byte, steps one +instruction, then patches the byte again. Without a gate, every other thread entering the same function in +that window runs the original byte and its call is never traced. The gate suspends the other threads for +the step and patches the byte again only once no thread is still stepping over it. +""" + + +class StepGate: + def __init__(self, suspend, resume, live): + self._suspend = suspend # tid -> bool, True when the thread is now suspended + self._resume = resume # tid -> None + self._live = live # callable returning the live thread ids + self.stepping = {} # tid -> address being stepped over + self._held = {} # tid -> suspend count held by the gate + self.dropped = 0 # steps begun while another thread was already stepping the same address + + def begin(self, tid, addr): + """A thread hit the hook at addr and is about to step. Returns True when addr was already open.""" + overlap = addr in self.stepping.values() + if overlap: + self.dropped += 1 + self.stepping[tid] = addr + for other in sorted(self._live()): + if other not in self.stepping and self._suspend(other): + self._held[other] = self._held.get(other, 0) + 1 ~~~~ --- **<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 -->
chatgpt-codex-connector[bot commented 2026-11-24 23:03:44 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T22:10:32Z.

Code review location: tools/startup/step_gate.py; line 45

@@ -0,0 +1,45 @@
+"""Keeps concurrent threads from running through a hooked byte while it is restored for a single step.
+
+A function-entry hook is one patched byte. The thread that hits it restores the original byte, steps one
+instruction, then patches the byte again. Without a gate, every other thread entering the same function in
+that window runs the original byte and its call is never traced. The gate suspends the other threads for
+the step and patches the byte again only once no thread is still stepping over it.
+"""
+
+
+class StepGate:
+    def __init__(self, suspend, resume, live):
+        self._suspend = suspend  # tid -> bool, True when the thread is now suspended
+        self._resume = resume  # tid -> None
+        self._live = live  # callable returning the live thread ids
+        self.stepping = {}  # tid -> address being stepped over
+        self._held = {}  # tid -> suspend count held by the gate
+        self.dropped = 0  # steps begun while another thread was already stepping the same address
+
+    def begin(self, tid, addr):
+        """A thread hit the hook at addr and is about to step. Returns True when addr was already open."""
+        overlap = addr in self.stepping.values()
+        if overlap:
+            self.dropped += 1
+        self.stepping[tid] = addr
+        for other in sorted(self._live()):
+            if other not in self.stepping and self._suspend(other):
+                self._held[other] = self._held.get(other, 0) + 1
+        return overlap
+
+    def finish(self, tid):
+        """The thread's step ended. Returns the address to patch again, or None while others still step it."""
+        addr = self.stepping.pop(tid, None)
+        if addr is None:
+            return None
+        if not self.stepping:
+            for other, count in list(self._held.items()):
+                for _ in range(count):
+                    self._resume(other)
+            self._held.clear()
+        return None if addr in self.stepping.values() else addr
+
+    def forget(self, tid):
+        """The thread exited; it can no longer be resumed or stepped."""
+        self.stepping.pop(tid, None)
+        self._held.pop(tid, None)

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 👍 / 👎.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4687231371 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1951#discussion_r4687231371). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-24T22:10:32Z. **Code review location:** `tools/startup/step_gate.py`; line 45 ~~~~diff @@ -0,0 +1,45 @@ +"""Keeps concurrent threads from running through a hooked byte while it is restored for a single step. + +A function-entry hook is one patched byte. The thread that hits it restores the original byte, steps one +instruction, then patches the byte again. Without a gate, every other thread entering the same function in +that window runs the original byte and its call is never traced. The gate suspends the other threads for +the step and patches the byte again only once no thread is still stepping over it. +""" + + +class StepGate: + def __init__(self, suspend, resume, live): + self._suspend = suspend # tid -> bool, True when the thread is now suspended + self._resume = resume # tid -> None + self._live = live # callable returning the live thread ids + self.stepping = {} # tid -> address being stepped over + self._held = {} # tid -> suspend count held by the gate + self.dropped = 0 # steps begun while another thread was already stepping the same address + + def begin(self, tid, addr): + """A thread hit the hook at addr and is about to step. Returns True when addr was already open.""" + overlap = addr in self.stepping.values() + if overlap: + self.dropped += 1 + self.stepping[tid] = addr + for other in sorted(self._live()): + if other not in self.stepping and self._suspend(other): + self._held[other] = self._held.get(other, 0) + 1 + return overlap + + def finish(self, tid): + """The thread's step ended. Returns the address to patch again, or None while others still step it.""" + addr = self.stepping.pop(tid, None) + if addr is None: + return None + if not self.stepping: + for other, count in list(self._held.items()): + for _ in range(count): + self._resume(other) + self._held.clear() + return None if addr in self.stepping.values() else addr + + def forget(self, tid): + """The thread exited; it can no longer be resumed or stepped.""" + self.stepping.pop(tid, None) + self._held.pop(tid, None) ~~~~ --- **<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 -->
tedin7 commented 2026-11-25 01:00:53 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T00:44:43Z.

Review: COMMENTED


No description provided.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6049796925 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1951#pullrequestreview-6049796925). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T00:44:43Z. **Review:** COMMENTED --- _No description provided._
tedin7 commented 2026-11-25 01:00:53 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T00:44:45Z.

Review: COMMENTED


No description provided.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6049797243 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1951#pullrequestreview-6049797243). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T00:44:45Z. **Review:** COMMENTED --- _No description provided._
tedin7 commented 2026-11-25 01:02:17 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T00:44:43Z.

Code review location: tools/startup/step_gate.py; line 27

@@ -0,0 +1,45 @@
+"""Keeps concurrent threads from running through a hooked byte while it is restored for a single step.
+
+A function-entry hook is one patched byte. The thread that hits it restores the original byte, steps one
+instruction, then patches the byte again. Without a gate, every other thread entering the same function in
+that window runs the original byte and its call is never traced. The gate suspends the other threads for
+the step and patches the byte again only once no thread is still stepping over it.
+"""
+
+
+class StepGate:
+    def __init__(self, suspend, resume, live):
+        self._suspend = suspend  # tid -> bool, True when the thread is now suspended
+        self._resume = resume  # tid -> None
+        self._live = live  # callable returning the live thread ids
+        self.stepping = {}  # tid -> address being stepped over
+        self._held = {}  # tid -> suspend count held by the gate
+        self.dropped = 0  # steps begun while another thread was already stepping the same address
+
+    def begin(self, tid, addr):
+        """A thread hit the hook at addr and is about to step. Returns True when addr was already open."""
+        overlap = addr in self.stepping.values()
+        if overlap:
+            self.dropped += 1
+        self.stepping[tid] = addr
+        for other in sorted(self._live()):
+            if other not in self.stepping and self._suspend(other):
+                self._held[other] = self._held.get(other, 0) + 1

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

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4688626150 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1951#discussion_r4688626150). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T00:44:43Z. **Code review location:** `tools/startup/step_gate.py`; line 27 ~~~~diff @@ -0,0 +1,45 @@ +"""Keeps concurrent threads from running through a hooked byte while it is restored for a single step. + +A function-entry hook is one patched byte. The thread that hits it restores the original byte, steps one +instruction, then patches the byte again. Without a gate, every other thread entering the same function in +that window runs the original byte and its call is never traced. The gate suspends the other threads for +the step and patches the byte again only once no thread is still stepping over it. +""" + + +class StepGate: + def __init__(self, suspend, resume, live): + self._suspend = suspend # tid -> bool, True when the thread is now suspended + self._resume = resume # tid -> None + self._live = live # callable returning the live thread ids + self.stepping = {} # tid -> address being stepped over + self._held = {} # tid -> suspend count held by the gate + self.dropped = 0 # steps begun while another thread was already stepping the same address + + def begin(self, tid, addr): + """A thread hit the hook at addr and is about to step. Returns True when addr was already open.""" + overlap = addr in self.stepping.values() + if overlap: + self.dropped += 1 + self.stepping[tid] = addr + for other in sorted(self._live()): + if other not in self.stepping and self._suspend(other): + self._held[other] = self._held.get(other, 0) + 1 ~~~~ --- 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 commented 2026-11-25 01:02:17 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T00:44:45Z.

Code review location: tools/startup/step_gate.py; line 45

@@ -0,0 +1,45 @@
+"""Keeps concurrent threads from running through a hooked byte while it is restored for a single step.
+
+A function-entry hook is one patched byte. The thread that hits it restores the original byte, steps one
+instruction, then patches the byte again. Without a gate, every other thread entering the same function in
+that window runs the original byte and its call is never traced. The gate suspends the other threads for
+the step and patches the byte again only once no thread is still stepping over it.
+"""
+
+
+class StepGate:
+    def __init__(self, suspend, resume, live):
+        self._suspend = suspend  # tid -> bool, True when the thread is now suspended
+        self._resume = resume  # tid -> None
+        self._live = live  # callable returning the live thread ids
+        self.stepping = {}  # tid -> address being stepped over
+        self._held = {}  # tid -> suspend count held by the gate
+        self.dropped = 0  # steps begun while another thread was already stepping the same address
+
+    def begin(self, tid, addr):
+        """A thread hit the hook at addr and is about to step. Returns True when addr was already open."""
+        overlap = addr in self.stepping.values()
+        if overlap:
+            self.dropped += 1
+        self.stepping[tid] = addr
+        for other in sorted(self._live()):
+            if other not in self.stepping and self._suspend(other):
+                self._held[other] = self._held.get(other, 0) + 1
+        return overlap
+
+    def finish(self, tid):
+        """The thread's step ended. Returns the address to patch again, or None while others still step it."""
+        addr = self.stepping.pop(tid, None)
+        if addr is None:
+            return None
+        if not self.stepping:
+            for other, count in list(self._held.items()):
+                for _ in range(count):
+                    self._resume(other)
+            self._held.clear()
+        return None if addr in self.stepping.values() else addr
+
+    def forget(self, tid):
+        """The thread exited; it can no longer be resumed or stepped."""
+        self.stepping.pop(tid, None)
+        self._held.pop(tid, None)

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

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4688626430 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1951#discussion_r4688626430). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T00:44:45Z. **Code review location:** `tools/startup/step_gate.py`; line 45 ~~~~diff @@ -0,0 +1,45 @@ +"""Keeps concurrent threads from running through a hooked byte while it is restored for a single step. + +A function-entry hook is one patched byte. The thread that hits it restores the original byte, steps one +instruction, then patches the byte again. Without a gate, every other thread entering the same function in +that window runs the original byte and its call is never traced. The gate suspends the other threads for +the step and patches the byte again only once no thread is still stepping over it. +""" + + +class StepGate: + def __init__(self, suspend, resume, live): + self._suspend = suspend # tid -> bool, True when the thread is now suspended + self._resume = resume # tid -> None + self._live = live # callable returning the live thread ids + self.stepping = {} # tid -> address being stepped over + self._held = {} # tid -> suspend count held by the gate + self.dropped = 0 # steps begun while another thread was already stepping the same address + + def begin(self, tid, addr): + """A thread hit the hook at addr and is about to step. Returns True when addr was already open.""" + overlap = addr in self.stepping.values() + if overlap: + self.dropped += 1 + self.stepping[tid] = addr + for other in sorted(self._live()): + if other not in self.stepping and self._suspend(other): + self._held[other] = self._held.get(other, 0) + 1 + return overlap + + def finish(self, tid): + """The thread's step ended. Returns the address to patch again, or None while others still step it.""" + addr = self.stepping.pop(tid, None) + if addr is None: + return None + if not self.stepping: + for other, count in list(self._held.items()): + for _ in range(count): + self._resume(other) + self._held.clear() + return None if addr in self.stepping.values() else addr + + def forget(self, tid): + """The thread exited; it can no longer be resumed or stepped.""" + self.stepping.pop(tid, None) + self._held.pop(tid, None) ~~~~ --- 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 commented 2026-11-25 11:02:32 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T10:48:08Z.


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

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7160191816 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1951#issuecomment-7160191816). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T10:48:08Z. --- @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.
R0Y00 commented 2026-11-25 13:00:26 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-25T12:37:19Z.

Review: CHANGES_REQUESTED


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6057715198 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1951#pullrequestreview-6057715198). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-25T12:37:19Z. **Review:** CHANGES_REQUESTED --- 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.
tedin7 commented 2026-11-25 14:05:11 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T13:47:01Z.


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7164283381 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1951#issuecomment-7164283381). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T13:47:01Z. --- 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 commented 2026-11-25 19:04:13 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T18:30:21Z.


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

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7170999054 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1951#issuecomment-7170999054). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T18:30:21Z. --- @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.
upstream-sync closed this pull request 2026-11-25 22:01:47 +00:00
tedin7 commented 2026-11-25 22:02:19 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T21:33:43Z.


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7175240850 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1951#issuecomment-7175240850). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T21:33:43Z. --- 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 commented 2026-11-26 11:03:00 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T10:37:38Z.


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7189615931 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1951#issuecomment-7189615931). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-26T10:37:38Z. --- 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 commented 2026-11-26 11:03:00 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T10:42:03Z.


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7189716182 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1951#issuecomment-7189716182). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-26T10:42:03Z. --- 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.
chatgpt-codex-connector[bot commented 2026-11-26 11:03:00 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-26T10:42:16Z.


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7189720894 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1951#issuecomment-7189720894). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-26T10:42:16Z. --- 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).
tedin7 commented 2026-11-26 11:03:02 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T10:51:55Z.


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7189939929 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1951#issuecomment-7189939929). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-26T10:51:55Z. --- 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.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
R0Y00/Xbox2Windows!1944
No description provided.