CrashReporter: fix deadlocks by making it mostly async-signal-safe (#5771)

`CrashReporter::createAndSaveCrash()` is not async-signal-safe,
resulting in random deadlocks/double-crashes during Hyprland crashes.
This changes the function to be (mostly) async-signal-safe.
This commit is contained in:
virchau13
2024-04-28 00:38:48 +08:00
committed by GitHub
parent 55490637aa
commit 90a53aed59
6 changed files with 351 additions and 70 deletions

View File

@@ -36,6 +36,14 @@ void handleUnrecoverableSignal(int sig) {
return;
}
// Kill the program if the crash-reporter is caught in a deadlock.
signal(SIGALRM, [](int _) {
char const* msg = "\nCrashReporter exceeded timeout, forcefully exiting\n";
write(2, msg, strlen(msg));
abort();
});
alarm(15);
CrashReporter::createAndSaveCrash(sig);
abort();