mirror of
https://github.com/tangerineturtle1/NX2navi.git
synced 2026-11-20 14:39:58 -04:00
Tell a crash on the RTSS thread as the game's own call of RivaTuner's library, and skip the restore there.
main.c foreign_hook matches "hook", so a crash in RTSSHooks64.dll got the line that the library is not part of the game and that a recording, overlay or capture program put it there, also when the game's own thread that sets the frame limit (rtss_limit.c's "rtss" worker) had loaded and called it. The one RTSS crash on record (issue #231) faulted in ntdll on that thread, where no note applied. And the crash handler then called rtss_limit_restore from that thread, whose own lock it holds (SRW locks are not recursive), so the restore's trylocks spent a second. The platform layer keeps the name a thread was made with in the thread itself (plat_thread_name, copied at its start: a detached thread's struct may go before it ends). main.c crash_module_note picks the note: on the "rtss" thread, whatever the module, the line says the fault is in the game's calls of RTSS's library or around them and that rtss = 0 keeps the game from calling it; on other threads RTSSHooks64.dll stays foreign, as it is RTSS's overlay there. The restore is skipped on the rtss thread. rtss_limit.c is unchanged: the thread is known by the name it is spawned with. Crash text only, besides the skipped restore. Not reproduced before the change. tests/foreign_hook_check.py checks the note's choice (RTSSHooks64.dll and ntdll on the RTSS thread: the RTSS note; RTSSHooks64.dll elsewhere: foreign; a driver: none), and tests/crash_stack_check.py that the crash report reads the faulting thread's name. They, thread_end_check, fatal_exit_check and the compile checks of every runtime file pass. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -331,6 +331,15 @@ static int foreign_hook(const char *module) {
|
||||
strstr(low, "reshade") || strstr(low, "obs-vulkan") || strstr(low, "nvspcap");
|
||||
}
|
||||
|
||||
// What the crash report says of the faulting module. A fault on the thread that hands the frame limit to RivaTuner
|
||||
// Statistics Server (rtss_limit.c, the "rtss" thread) is in the game's own calls of RTSS's library or around them,
|
||||
// whatever module it is in (the one such crash faulted in ntdll): the note names that and the setting that keeps the
|
||||
// game from calling it. On other threads RTSS's library is its overlay, which RTSS put there: foreign_hook's note.
|
||||
enum { CRASH_NOTE_NONE, CRASH_NOTE_FOREIGN, CRASH_NOTE_RTSS };
|
||||
static int crash_module_note(const char *module, int on_rtss_thread) {
|
||||
return on_rtss_thread ? CRASH_NOTE_RTSS : foreign_hook(module) ? CRASH_NOTE_FOREIGN : CRASH_NOTE_NONE;
|
||||
}
|
||||
|
||||
// Set when main_run has returned: the mode's work is done and saved, and all that still runs is the C runtime's exit
|
||||
// and, inside ExitProcess, the detach call of every library in the process, the graphics driver's and those other
|
||||
// programs put there. A fault in one of them is not a failure of the run. On one PC an injector's Vulkan layer faulted
|
||||
@@ -363,9 +372,16 @@ static void crash_handler(const PlatCrash *x) {
|
||||
rt_logf(", %s address %#llx", x->access == 1 ? "writing" : x->access == 8 ? "executing" : "reading",
|
||||
(unsigned long long)x->addr);
|
||||
rt_log_raw("\n", 1);
|
||||
if (foreign_hook(x->module))
|
||||
const char *thread = plat_thread_name();
|
||||
int on_rtss = thread && !strcmp(thread, "rtss");
|
||||
int module_note = crash_module_note(x->module, on_rtss);
|
||||
if (module_note == CRASH_NOTE_FOREIGN)
|
||||
rt_logf(" %s is not part of the game: a recording, overlay or capture program put it into the game. Close that "
|
||||
"program or turn off its Vulkan capture, then start the game again\n", x->module);
|
||||
else if (module_note == CRASH_NOTE_RTSS)
|
||||
rt_logf(" the fault is on the thread that hands the frame limit to RivaTuner Statistics Server (rtss_limit.c), "
|
||||
"in the game's calls of its library or around them; rtss = 0 in nx2navi.ini keeps the game from calling "
|
||||
"it\n");
|
||||
// what the thread was doing (a pipeline build names its shaders): the stderr note crash_veh writes misses the log
|
||||
const char *note = plat_crash_context_get();
|
||||
if (note) rt_logf(" the thread was %s\n", note);
|
||||
@@ -399,7 +415,9 @@ static void crash_handler(const PlatCrash *x) {
|
||||
rt_fatal_notes(); // the card, its driver and the memory settings in effect (vk_device.c fatal_note)
|
||||
kern_free_cores_note();
|
||||
fs_save_crash_wait(); // a save the game already reported as done finishes first (bounded; fs_host.c)
|
||||
rtss_limit_restore(); // after the report: RivaTuner Statistics Server's profile as it was
|
||||
// after the report: RivaTuner Statistics Server's profile as it was; not from its own thread, which holds the lock
|
||||
// the restore would try for a second
|
||||
if (!on_rtss) rtss_limit_restore();
|
||||
rt_rumble_stop_bounded(); // a controller on HD rumble stops (dispatch.c: 300 ms at most, SDL may be the crash)
|
||||
fflush(stderr);
|
||||
prof_sampler_write(); // NX2NAVI_PROFILE: what was sampled until the crash (it gives up after 2 s if the sampler hangs)
|
||||
|
||||
Reference in New Issue
Block a user