try to prevent potential infinite SIGARBT hang in signal handler

This commit is contained in:
Alug committed 2024-07-28 15:37:23 +02:00
1 parent cca082b091
commit f71631e732
3 files changed
+12 -2

No files matched your search

+6 -2
View File
@@ -43,8 +43,12 @@
#ifdef HAVE_THREADS
I_mutex con_mutex;
# define Lock_state() I_lock_mutex(&con_mutex)
# define Unlock_state() I_unlock_mutex(con_mutex)
// g_in_exiting_signal_handler is an evil hack
// to avoid infinite SIGABRT recursion in the signal handler
// due to poisoned locks or mach-o kernel not supporting locks in signals
// or something like that. idk
# define Lock_state() if (!g_in_exiting_signal_handler) { I_lock_mutex(&con_mutex); }
# define Unlock_state() if (!g_in_exiting_signal_handler) { I_unlock_mutex(con_mutex); }
#else/*HAVE_THREADS*/
# define Lock_state()
# define Unlock_state()
+3
View File
@@ -34,6 +34,9 @@ extern UINT8 graphics_started;
*/
extern UINT8 keyboard_started;
/** \brief Set to true when inside a signal handler that will exit the program. */
extern boolean g_in_exiting_signal_handler;
/** \brief The I_GetFreeMem function
\param total total memory in the system
+3
View File
@@ -450,6 +450,7 @@ SDL_bool consolevent = SDL_FALSE;
SDL_bool framebuffer = SDL_FALSE;
UINT8 keyboard_started = false;
boolean g_in_exiting_signal_handler = false;
static void I_ReportSignal(int num, int coredumped)
{
@@ -516,6 +517,8 @@ static void I_ReportSignal(int num, int coredumped)
#ifndef NEWSIGNALHANDLER
FUNCNORETURN static ATTRNORETURN void signal_handler(INT32 num)
{
g_in_exiting_signal_handler = true;
D_QuitNetGame(); // Fix server freezes
#ifdef HAVE_LIBBACKTRACE