Skip to content

Hang watch: each game event and semaphore keeps its last operations - #47

Merged
ThatRecompDev merged 2 commits into
ThatRecompDev:mainfrom
Sr-0w:diagnostics/wait-object-history
Nov 25, 2026
Merged

ThatRecompDev merged 2 commits into
ThatRecompDev:mainfrom
Sr-0w:diagnostics/wait-object-history

Conversation

@Sr-0w

@Sr-0w Sr-0w commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

A game run reached the opening cutscene, then hit the game's 30 s watchdog. The wait-object report showed a cycle:

  • the main thread waits on a semaphore that a worker (A) no longer releases;
  • A waits on an auto-reset "idle" event of a second worker (B);
  • B waits on a wake event that only A sets.

B had signaled the idle event 0.2 s before A started waiting on it. So the signal was either taken by another wait or dropped in between. The report couldn't tell which: it kept only the last signal, and the shims saw neither ResetEvent nor WaitForMultipleObjects, though the game imports both.

Change:

  • Each object now keeps its last 12 operations: signaled, reset, wait, wait on any/all of N, woke, timed out. Each comes with the thread, the time before the dump and the game's calling address. The blocked-wait report lists them after the signal count.
  • ResetEvent and WaitForMultipleObjects get pass-through shims under --watch-hang, like the other wait-object calls. They are removed otherwise.

Test: a signal, a multi-object wait that it ends, a reset and a blocked wait are listed in order with their threads, and the wake-up that follows is recorded. Loader tests and architecture rules pass. Docs are in debugging.md.

🤖 Generated with Claude Code

@ThatRecompDev

ThatRecompDev commented Nov 25, 2026 •

Copy link
Copy Markdown
Owner

this is really useful, the "signaled 0.2 s before the wait" story is exactly what the old report couldn't show.

couple of things before merging though:

Signaled and Done now call Caller(), which does the full 64 KB / 6-frame scan on every SetEvent/ReleaseSemaphore/ResetEvent and every wake, just to keep the first address. with the hang watch on, that adds work to exactly the paths whose timing we're watching. could you scan for 1 frame there (or reuse the frames the wait already found)?

DoneOnSeveral drops timeouts and abandoned results, so a multi-wait that times out leaves nothing, while single waits record "timed out".

the blocked line only names handles[0] for a multi wait, maybe say "one of N".

off-mode is fine, since the shims get removed without --watch-hang.

heads up too: main got a fix in ReturnAddresses.Scan last night (it only reads the call bytes when their page is committed, 98d9727). it crashed a boot from inside the wait shim, so more Caller() calls go through that path now

Sr-0w and others added 2 commits November 25, 2026 22:19
A game run reached the opening cutscene, then hit the game's 30 s
watchdog: the main thread waited on a semaphore a worker no longer
released, that worker waited on an auto-reset "idle" event of a second
worker, and the second waited on a wake event only the first sets. The
idle event had been signaled 0.2 s before the first worker started to
wait on it, so the signal was taken or dropped in between, but the
report only kept the last signal and the shims saw neither ResetEvent
nor WaitForMultipleObjects, both of which the game imports.

Each object now keeps its last 12 operations (signaled, reset, wait,
woke, timed out, or a multi-object wait), with the thread, the time and
the game's calling address, and the blocked-wait report lists them.
ResetEvent and WaitForMultipleObjects get pass-through shims under
--watch-hang like the other wait-object calls.

Test: a signal, a multi-object wait that it ends, a reset and a blocked
wait are listed in order with their threads; the wake-up that follows
is recorded.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…names all of them

Review of ThatRecompDev#47:
- Signals, resets and wake-ups scan the stack for one game frame only (they run on the paths the hang watch times).
- A wait on several objects that times out, fails or ends on an abandoned mutex records that on its objects
  (the abandoned one, or all), and a wait on all of them records the wake-up on each.
- The blocked line of a wait on several names them all: one of N (or all of N) handles, the first described.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Sr-0w
Sr-0w force-pushed the diagnostics/wait-object-history branch from 5a1cea7 to 6009163 Compare November 25, 2026 21:21
@Sr-0w

Sr-0w commented Nov 25, 2026

Copy link
Copy Markdown
Contributor Author

Thanks, done (rebased on main, so it goes through 98d9727's CallBytesReadable):

  • Caller cost: Signaled, Reset and every wake-up now scan for one frame (GameFrames(1)), stopping at the first game return address. Creations and waits keep 6 frames, and DoneOnSeveral scans once for all its objects.
  • multi-wait results: DoneOnSeveral takes all and records the result on the objects:
    • timeout or failure → "timed out" / "wait returned 0x.." on every object;
    • WAIT_ABANDONED_0 + i → "abandoned" on that object;
    • a successful wait-all → "woke" on each object.
  • blocked line: a wait on several now reads on one of 3 handles (0x.., 0x.., 0x..), the first 0x..: <first described> (or all of).

New test A_wait_on_several_objects_names_them_all_and_its_timeout_stays_on_each. WaitObjects tests 11/11.

@Sr-0w

Sr-0w commented Nov 25, 2026

Copy link
Copy Markdown
Contributor Author

In game: this history is what found the watchdog cause fixed by #49. The run with it showed:

  • the frame thread waiting on the "last worker done" event;
  • 4 workers asleep;
  • the 5th still Running in CreatePipelineState at 5, 15 and 25 s.

That ruled out a lost wake-up. With #49 on top, runs reach the opening cinematic (loading screens at 30 fps, then the world at 9–14 fps) and last 600 s without the watchdog.

@ThatRecompDev
ThatRecompDev merged commit 54b66e1 into ThatRecompDev:main Nov 25, 2026
0 of 2 checks passed
ThatRecompDev added a commit that referenced this pull request Nov 25, 2026
@ThatRecompDev

Copy link
Copy Markdown
Owner

thanks, all three changes are in and they read well. the one-frame scan in Signaled/Done, timeouts and abandoned results recorded for multi-waits, and the "one of N" wording.

merged into main (566a88d). i fixed one architecture rule on the way in (the property pattern in Target became a local and a plain null check), so no need to touch it.

two small things if you ever come back to it: a signal from a thread with no game frames still scans the full 64 KB, and the WaitForMultipleObjects shim reads the handle array before kernel32 does, so a bad pointer would crash instead of returning WAIT_FAILED. not urgent

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants