diff --git a/src/main.cpp b/src/main.cpp index 94b54c0d..aa50229b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -30,18 +30,19 @@ using namespace rack; static void fatalSignalHandler(int sig) { - // Only catch one signal - static bool caught = false; - bool localCaught = caught; - caught = true; - if (localCaught) - exit(1); + // Ignore this signal to avoid recursion. + signal(sig, NULL); + // Ignore abort() since we call it below. + signal(SIGABRT, NULL); FATAL("Fatal signal %d. Stack trace:\n%s", sig, system::getStackTrace().c_str()); - osdialog_message(OSDIALOG_ERROR, OSDIALOG_OK, "Rack has crashed. See log.txt for details."); + // This might fail because we might not be in the main thread. + // But oh well, we're crashing anyway. + std::string text = app::APP_NAME + " has crashed. See log.txt for details."; + osdialog_message(OSDIALOG_ERROR, OSDIALOG_OK, text.c_str()); - exit(1); + abort(); } @@ -97,8 +98,7 @@ int main(int argc, char *argv[]) { logger::init(); // We can now install a signal handler and log the output - // Mac has its own decent crash handler -#if defined ARCH_LIN +#if defined ARCH_LIN || defined ARCH_MAC if (!settings::devMode) { signal(SIGABRT, fatalSignalHandler); signal(SIGFPE, fatalSignalHandler); diff --git a/src/system.cpp b/src/system.cpp index d864964d..f3215650 100644 --- a/src/system.cpp +++ b/src/system.cpp @@ -171,10 +171,11 @@ std::string getStackTrace() { // Skip the first line because it's this function. for (int i = 1; i < stackLen; i++) { s += string::f("%d: ", stackLen - i - 1); + std::string line = strings[i]; +#if 0 // Parse line std::regex r(R"((.*)\((.*)\+(.*)\) (.*))"); std::smatch match; - std::string line = strings[i]; if (std::regex_search(line, match, r)) { s += match[1].str(); s += "("; @@ -190,6 +191,9 @@ std::string getStackTrace() { s += match[3].str(); s += ")"; } +#else + s += line; +#endif s += "\n"; } free(strings);