From 3d742161495c7fa3ad6c345226d709575c5720e3 Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Wed, 5 Apr 2023 08:13:55 +0200 Subject: [PATCH] Make strsignal(SIGSEGV) return the same string across all architectures --- src/mc/explo/Exploration.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/mc/explo/Exploration.cpp b/src/mc/explo/Exploration.cpp index 5d35347678..ceac33e163 100644 --- a/src/mc/explo/Exploration.cpp +++ b/src/mc/explo/Exploration.cpp @@ -68,14 +68,25 @@ void Exploration::log_state() XBT_WARN("Call to system(free) did not return 0, but %d", ret); } } - +// Make our tests fully reproducible despite the subtle differences of strsignal() across archs +static const char* signal_name(int status) +{ + switch (WTERMSIG(status)) { + case SIGABRT: // FreeBSD uses "Abort trap" as a strsignal for SIGABRT + return "Aborted"; + case SIGSEGV: // MacOSX uses "Segmentation fault: 11" for SIGKILL + return "Segmentation fault"; + default: + return strsignal(WTERMSIG(status)); + } +} XBT_ATTRIB_NORETURN void Exploration::report_crash(int status) { XBT_INFO("**************************"); XBT_INFO("** CRASH IN THE PROGRAM **"); XBT_INFO("**************************"); - if (WIFSIGNALED(status)) // FreeBSD use "Abort trap" as a strsignal for SIGABRT that is part of our tests - XBT_INFO("From signal: %s", WTERMSIG(status) == SIGABRT ? "Aborted" : strsignal(WTERMSIG(status))); + if (WIFSIGNALED(status)) + XBT_INFO("From signal: %s", signal_name(status)); else if (WIFEXITED(status)) XBT_INFO("From exit: %i", WEXITSTATUS(status)); if (not xbt_log_no_loc) -- 2.20.1