Diagnostics: the hang watch names the event or semaphore each blocked thread waits on #31

Manually merged
github merged 1 commit from gh-pr/31/head into gh-pr/31/base 2026-11-27 03:14:40 +00:00
Owner

@⁠Sr-0w on GitHub · 2026-11-25 13:35 UTC · original
Sr-0w:diagnostics/wait-objects → main · +509 −2 · 10 files · 1 commits · merged 2026-11-25 14:00 UTC

A retail game's 30 s watchdog fired in this state:

  • its main thread was polling an event that a worker never set;
  • the worker was in an infinite wait on another object;
  • the pool threads were asleep on their semaphores.

The stacks showed who was waiting, but not which object, nor whether anything still signals it.

With --watch-hang, the loader now keeps shims on the game's CreateEventW/A, CreateSemaphoreExW, SetEvent, ReleaseSemaphore, CloseHandle and WaitForSingleObject(Ex) (WaitObjectShims). Without the flag they are removed, so a normal run still calls kernel32 directly.

WaitObjects records, for each object:

  • its kind;
  • the creating thread, the time and the game frames of the creating call;
  • its signals, and which thread gave the last one.

It also records each thread's wait in progress. The hang dump lists every thread blocked for a second or more, with the handle, the timeout, how the object was created, and its last signal or "never signaled".

Tests:

  • A thread blocked on an event that is never set is reported with its event and creator.
  • Once the event is set, the signal is recorded and the wait no longer appears.
  • Full suite green locally.

Docs: debugging.md (Hang watchdog) and the --watch-hang row in loader.md.

🤖 Generated with Claude Code

**@⁠Sr-0w** on GitHub · 2026-11-25 13:35 UTC · [original](https://github.com/ThatRecompDev/five-star-recomp/pull/31) `Sr-0w:diagnostics/wait-objects` → `main` · +509 −2 · 10 files · 1 commits · merged 2026-11-25 14:00 UTC A retail game's 30 s watchdog fired in this state: - its main thread was polling an event that a worker never set; - the worker was in an infinite wait on another object; - the pool threads were asleep on their semaphores. The stacks showed who was waiting, but not which object, nor whether anything still signals it. With `--watch-hang`, the loader now keeps shims on the game's `CreateEventW/A`, `CreateSemaphoreExW`, `SetEvent`, `ReleaseSemaphore`, `CloseHandle` and `WaitForSingleObject(Ex)` (`WaitObjectShims`). Without the flag they are removed, so a normal run still calls kernel32 directly. `WaitObjects` records, for each object: - its kind; - the creating thread, the time and the game frames of the creating call; - its signals, and which thread gave the last one. It also records each thread's wait in progress. The hang dump lists every thread blocked for a second or more, with the handle, the timeout, how the object was created, and its last signal or "never signaled". Tests: - A thread blocked on an event that is never set is reported with its event and creator. - Once the event is set, the signal is recorded and the wait no longer appears. - Full suite green locally. Docs: `debugging.md` (Hang watchdog) and the `--watch-hang` row in `loader.md`. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
A retail game's 30 s watchdog fired with its main thread polling an
event that a worker never set, the worker blocked in an infinite wait
on another object and the pool threads asleep on their semaphores: the
stacks showed who waits, not on what nor whether anyone still signals it.

With --watch-hang the loader keeps shims on the game's CreateEventW/A,
CreateSemaphoreExW, SetEvent, ReleaseSemaphore, CloseHandle and
WaitForSingleObject(Ex) (WaitObjectShims, removed otherwise, so a normal
run calls kernel32 directly). WaitObjects records each object's kind,
creating thread, time and game frames, its signals and the thread that
gave the last, and each thread's wait in progress. The hang dump lists
every thread blocked a second or more with the handle, the timeout, the
object's creation and its last signal or "never signaled".

Tests: a thread blocked on a never-set event is reported with its event
and creator; once set, the signal is recorded and the wait is gone.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 03:14:38 +00:00
github manually merged commit 01af90dd05 into gh-pr/31/base 2026-11-27 03:14:40 +00:00
Author
Owner

@⁠ThatRecompDev on GitHub · 2026-11-25 14:00 UTC · original

great diagnostic, merged. danik's intro path sits on the story load until the watchdog with the loader idle, so knowing which event nobody ever sets is exactly what we need there.

**@⁠ThatRecompDev** on GitHub · 2026-11-25 14:00 UTC · [original](https://github.com/ThatRecompDev/five-star-recomp/pull/31#issuecomment-7164623109) great diagnostic, merged. danik's intro path sits on the story load until the watchdog with the loader idle, so knowing which event nobody ever sets is exactly what we need there.
This discussion has been locked. Commenting is limited to contributors.
No description provided.