From f00d82a1024a4e0f50f2da309625c1b6fde14cc8 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Cl=C3=A9ment=20DAVID?= Date: Thu, 23 Jun 2016 11:19:14 +0200 Subject: [PATCH] Linux segfault management: initialize strsignals on the main thread Some tests lock on OpenTCLsci() / pthread_cond_wait(), the watchdog_thread kill the process and should trigger a stacktrace display *BUT* strsignal() (used to have a readable signal name) call a thread unsafe pthread_once() that deadlock everything. This commit is a try to initialize signal names at process startup. Change-Id: I62a34bf49a559b4ce1fafb94224b1062c912538e --- scilab/modules/core/src/c/signal_mgmt.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/scilab/modules/core/src/c/signal_mgmt.c b/scilab/modules/core/src/c/signal_mgmt.c index c0fc135..b948e4c 100644 --- a/scilab/modules/core/src/c/signal_mgmt.c +++ b/scilab/modules/core/src/c/signal_mgmt.c @@ -88,17 +88,9 @@ static void sig_fatal(int signum, siginfo_t * info, void *p) /* This list comes from OpenMPI sources */ #ifdef HAVE_STRSIGNAL - /* On segfault, avoid calling strsignal which may allocate some memory (through gettext) */ { char* str; - if (signum == 11) - { - str = "Segmentation fault"; - } - else - { - str = strsignal(signum); - } + str = strsignal(signum); ret = snprintf(tmp, size, HOSTFORMAT "Signal: %s (%d)\n", stacktrace_hostname, getpid(), str, signum); } #else @@ -489,6 +481,11 @@ void base_error_init(void) fprintf(stderr, "Could not set handler for signal %d\n", signals[j]); } } + +#ifdef HAVE_STRSIGNAL + // initialize the glibc internal string representation. + strsignal(SIGABRT); +#endif } static void* watchdog_thread(void* arg) -- 1.7.9.5