mirror of
https://github.com/RetroPortingToolKit/psxrecomp
synced 2026-10-26 10:19:47 -04:00
430c93b8a4
starvation_watchdog_check() sampled the clock before loading the heartbeat, but the heartbeat is also stamped by the debug-server IO thread on every send() chunk. A stamp landing between the two reads made last > now, the uint64 subtraction wrapped past any threshold, and a healthy runtime exited with code 2 (BoF3 2026-09-02: 402 us of real staleness tripped the 4 s watchdog within ~2 min whenever the area poller was attached). - Load the heartbeat first, decide through the new pure helper starvation_watchdog_stale(), which refuses a negative gap by construction (same shape as the frame_pacing_sleep_ms fix). - Make s_last_heartbeat_us _Atomic with relaxed store/load. - Tag the exit origin: "starvation_watchdog" on the trip, console_close / console_ctrl_break / console_ctrl_c in the Win32 console handler, and signal_sigint / signal_sigterm in the soft-exit handler. These all used to reach psx_atexit_handler as atexit/unknown, indistinguishable from an SDL window close. - Add starvation_watchdog_test (ctest) pinning the decision function. Verified on BoF3 build-dbg: 10 min soak with the poller polling at 1 s and the watchdog enabled at its 4 s default, no dump, process alive; forced trip with PSX_STARVATION_TIMEOUT_US=1000 fires and the run report reads exit_origin "starvation_watchdog". Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>