Skip RivaTuner's restore at a fatal error on the RTSS thread too, not only at a crash there.

The review of the RTSS thread change found that only main.c crash_handler skipped rtss_limit_restore on the "rtss"
thread. An rt_fatal on that thread while it holds rtss_limit.c's lock still called the restore from dispatch.c
fatal_end, whose trylocks then spent a second for nothing before the end went on. A-14 names fatal_end.

fatal_end now reads plat_thread_name and calls rtss_limit_restore only when the thread is not "rtss", as
crash_handler does.

Not reproduced in the game before the change. tests/fatal_exit_check.c's stand-in restore now says it ran, and a new
fatal_rtss mode calls rt_fatal on a thread spawned with the name "rtss": on the code before this change the restore
ran there (the check fails), now it does not, and the process still ends with 70 after the rumble stop. The other
cases check that the restore runs from any other thread. fatal_exit_check and the compile check of dispatch.c pass,
with no -Wall warnings.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
chrg6
2026-11-13 18:28:09 -05:00
parent 78e9d23211
commit e6a6d6a809
3 changed files with 23 additions and 6 deletions

View File

@@ -118,8 +118,11 @@ static void fatal_end(int code, const char *fmt, va_list ap) {
fs_save_crash_wait(); // a save the game already reported as done finishes first (bounded)
prof_sampler_write(); // NX2NAVI_PROFILE: what was sampled until now, else a crash loses the whole profile
// RivaTuner Statistics Server's profile as it was: left with the game's limit in it, the next run would take that
// limit for the player's own (rtss_limit.c; it gives up after a second if the failing thread holds its lock)
rtss_limit_restore();
// limit for the player's own (rtss_limit.c; it gives up after a second if the failing thread holds its lock). Not
// from RTSS's own thread, which may hold that lock: the restore would spend its second for nothing (as in main.c
// crash_handler).
const char *thread = plat_thread_name();
if (!thread || strcmp(thread, "rtss")) rtss_limit_restore();
rt_rumble_stop_bounded(); // a controller on HD rumble: nothing renews or stops its vibration after the end
// "frametime: at a fatal error" and the stutter map, the session's last period: after what a kill of the process
// must not lose, as in the orderly end (gfx_present.c rt_exit_steps); ft_stop waits up to 50 ms