Skip to content

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

Merged
ThatRecompDev merged 1 commit into
ThatRecompDev:mainfrom
Sr-0w:diagnostics/wait-objects
Nov 25, 2026
Merged

ThatRecompDev merged 1 commit into
ThatRecompDev:mainfrom
Sr-0w:diagnostics/wait-objects

Conversation

@Sr-0w

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

Copy link
Copy Markdown
Contributor

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

… thread waits on

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 <noreply@anthropic.com>
@ThatRecompDev
ThatRecompDev merged commit cec71de into ThatRecompDev:main Nov 25, 2026
2 checks passed
@ThatRecompDev

Copy link
Copy Markdown
Owner

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.

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