From 2c50b6a41a82011969859ac0edc1df21c436823d Mon Sep 17 00:00:00 2001 From: Eidolon Date: Sun, 19 Nov 2023 10:38:19 -0600 Subject: [PATCH] Partial revert "sdl/i_system.cpp: fix compiler errors" This reverts commit bca2c8cb194f125552c9feb8ad482f1003e4880b. The changes to I_ReportSignal introduced implicit calls to malloc. malloc is not signal-safe. --- src/sdl/i_system.cpp | 65 ++++++++++++++++++++++++-------------------- 1 file changed, 36 insertions(+), 29 deletions(-) diff --git a/src/sdl/i_system.cpp b/src/sdl/i_system.cpp index 54ba51ed0..4c0f12947 100644 --- a/src/sdl/i_system.cpp +++ b/src/sdl/i_system.cpp @@ -25,8 +25,6 @@ #include -#include - #include #ifdef _WIN32 @@ -371,52 +369,61 @@ static void I_ShowErrorMessageBox(const char *messagefordevelopers, boolean dump static void I_ReportSignal(int num, int coredumped) { //static char msg[] = "oh no! back to reality!\r\n"; - auto report = [coredumped](std::string sigmsg) - { - if (coredumped) - { - sigmsg += " (core dumped)"; - } - - I_OutputMsg("\nProcess killed by signal: %s\n\n", sigmsg.c_str()); - - I_ShowErrorMessageBox(sigmsg.c_str(), -#if defined (UNIXBACKTRACE) - true -#elif defined (_WIN32) - !M_CheckParm("-noexchndl") -#else - false -#endif - ); - }; + const char * sigmsg; + char msg[128]; switch (num) { // case SIGINT: -// report("SIGINT - interrupted"); +// sigmsg = "SIGINT - interrupted"; // break; case SIGILL: - report("SIGILL - illegal instruction - invalid function image"); + sigmsg = "SIGILL - illegal instruction - invalid function image"; break; case SIGFPE: - report("SIGFPE - mathematical exception"); + sigmsg = "SIGFPE - mathematical exception"; break; case SIGSEGV: - report("SIGSEGV - segment violation"); + sigmsg = "SIGSEGV - segment violation"; break; // case SIGTERM: -// report("SIGTERM - Software termination signal from kill"); +// sigmsg = "SIGTERM - Software termination signal from kill"; // break; // case SIGBREAK: -// report("SIGBREAK - Ctrl-Break sequence"); +// sigmsg = "SIGBREAK - Ctrl-Break sequence"; // break; case SIGABRT: - report("SIGABRT - abnormal termination triggered by abort call"); + sigmsg = "SIGABRT - abnormal termination triggered by abort call"; break; default: - report(fmt::format("signal number {}", num)); + sprintf(msg,"signal number %d", num); + if (coredumped) + sigmsg = 0; + else + sigmsg = msg; } + + if (coredumped) + { + if (sigmsg) + sprintf(msg, "%s (core dumped)", sigmsg); + else + strcat(msg, " (core dumped)"); + + sigmsg = msg; + } + + I_OutputMsg("\nProcess killed by signal: %s\n\n", sigmsg); + + I_ShowErrorMessageBox(sigmsg, +#if defined (UNIXBACKTRACE) + true +#elif defined (_WIN32) + !M_CheckParm("-noexchndl") +#else + false +#endif + ); } #ifndef NEWSIGNALHANDLER