mirror of
https://github.com/tangerineturtle1/NX2navi.git
synced 2026-11-18 17:29:57 -04:00
Stop HD rumble at a fatal error and a crash too, on a thread of its own the end waits for 300 ms at most.
input_rumble_hd_stop ran only in the orderly ends, so a FATAL or a crash while a controller vibrated on HD rumble left it buzzing: nothing renews or stops the value after the process is gone (input.c says so). It also took hd_lock with a blocking lock while it only tried the other two. dispatch.c rt_rumble_stop_bounded runs input_rumble_hd_stop (weak in dispatch.c, as fs_save_crash_wait is, for builds without input.c) on a new "rumble stop" thread and waits at most 300 ms for it, never joining it: the stop goes through SDL, which takes its own joystick lock, and a crash on SDL's thread while it held that lock would otherwise keep the ending thread there and the process would never end. fatal_end and main.c crash_handler call it right after rtss_limit_restore. input.c tries hd_lock 50 times 1 ms apart, as it does `lock` and sdl_lock, and skips the stop when it is not taken. Not reproduced before the change. tests/fatal_exit_check.py (now linking dispatch.c as its own unit: the stop runs at a fatal error; a stop that hangs leaves the end at code 70 after 0.3 s; statically both failed ends call the bounded stop after the RTSS restore), tests/rumble_hd_check.py and the compile checks pass. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -7,14 +7,16 @@
|
||||
// fatal_exit_check crash_crash two threads fault at once: one whole crash report, exit code 71
|
||||
// fatal_exit_check fatal_crash a fault on another thread while rt_fatal reports: its FATAL line alone, exit code 70
|
||||
// fatal_exit_check crash_fatal rt_fatal on another thread while a crash is reported: the whole report, exit code 71
|
||||
// fatal_exit_check fatal_rumble rt_fatal while the HD rumble stop hangs (SDL's lock held): exit code 70 all the same
|
||||
//
|
||||
// The crash handler here is a stand-in for main.c crash_handler with its first line (the static check in
|
||||
// tests/fatal_exit_check.py holds main.c to it): it writes three report lines 100 ms apart and ends with plat_exit(71).
|
||||
#include "dispatch.c"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <windows.h>
|
||||
|
||||
#include "host.h"
|
||||
#include "platform/platform.h"
|
||||
|
||||
static void say(const char *s) {
|
||||
DWORD w;
|
||||
WriteFile(GetStdHandle(STD_OUTPUT_HANDLE), s, (DWORD)strlen(s), &w, NULL);
|
||||
@@ -58,6 +60,13 @@ void prof_sampler_write(void) {}
|
||||
void rtss_limit_restore(void) {}
|
||||
void kern_checkpoint(void) {}
|
||||
|
||||
// input.c's stop, which dispatch.c calls through a weak symbol: says it ran, or hangs as when SDL's lock is held
|
||||
static int rumble_hangs;
|
||||
void input_rumble_hd_stop(void) {
|
||||
if (rumble_hangs) Sleep(INFINITE);
|
||||
say("rumble: stopped\n");
|
||||
}
|
||||
|
||||
// ---- the crash report and the threads that fail beside it
|
||||
static void crash(const PlatCrash *x) {
|
||||
if (!rt_ending_enter()) plat_exit(71); // main.c crash_handler's first line
|
||||
@@ -93,6 +102,10 @@ int main(int argc, char **argv) {
|
||||
tls_var = 1;
|
||||
plat_crash_hook(crash);
|
||||
if (!strcmp(mode, "fatal")) rt_fatal("the test's fatal error %d", 1);
|
||||
if (!strcmp(mode, "fatal_rumble")) {
|
||||
rumble_hangs = 1;
|
||||
rt_fatal("the test's fatal error %d", 1);
|
||||
}
|
||||
if (!strcmp(mode, "crash_crash")) {
|
||||
CloseHandle(CreateThread(NULL, 0, fault, (void *)0, 0, NULL));
|
||||
CloseHandle(CreateThread(NULL, 0, fault, (void *)0, 0, NULL));
|
||||
@@ -113,6 +126,6 @@ int main(int argc, char **argv) {
|
||||
fault(0);
|
||||
return 3;
|
||||
}
|
||||
printf("usage: fatal_exit_check fatal|crash_crash|fatal_crash|crash_fatal\n");
|
||||
printf("usage: fatal_exit_check fatal|crash_crash|fatal_crash|crash_fatal|fatal_rumble\n");
|
||||
return 2;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user