From 34f2f42cccff62773dd710b695bdfd1363b85d45 Mon Sep 17 00:00:00 2001 From: mquinson Date: Tue, 7 Dec 2010 08:46:46 +0000 Subject: [PATCH] don't try to compute the backtrace if we have no process name (only occure with *badly* written bindings, but saves a segfault then) git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@9020 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- src/xbt/backtrace_linux.c | 3 +++ src/xbt/ex.c | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/src/xbt/backtrace_linux.c b/src/xbt/backtrace_linux.c index be2ebc476b..0401eebb7d 100644 --- a/src/xbt/backtrace_linux.c +++ b/src/xbt/backtrace_linux.c @@ -60,6 +60,9 @@ void xbt_ex_setup_backtrace(xbt_ex_t * e) && e->used, "Backtrace not setup yet, cannot set it up for display"); + if (!xbt_binary_name) /* no binary name, nothing to do */ + return; + backtrace_syms = backtrace_symbols(e->bt, e->used); /* ignore first one, which is this xbt_backtrace_current() */ e->used--; diff --git a/src/xbt/ex.c b/src/xbt/ex.c index cd6d584573..1b141a4d9b 100644 --- a/src/xbt/ex.c +++ b/src/xbt/ex.c @@ -153,6 +153,10 @@ void xbt_ex_display(xbt_ex_t * e) { int i; + if (!xbt_binary_name) { + fprintf(stderr, "variable 'xbt_binary_name' set to NULL. Cannot compute the backtrace\n"); + return; + } fprintf(stderr, "\n"); for (i = 0; i < e->used; i++) fprintf(stderr, "%s\n", e->bt_strings[i]); -- 2.20.1