Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Parmap: make maestro also do some work.
[simgrid.git] / src / xbt / backtrace_linux.c
index e57e486..966070a 100644 (file)
@@ -28,6 +28,12 @@ void xbt_backtrace_postexit(void)
 void xbt_backtrace_current(xbt_ex_t * e)
 {
   e->used = backtrace((void **) e->bt, XBT_BACKTRACE_SIZE);
+  if (e->used == 0) {
+    fprintf(stderr, "The backtrace() function failed, which probably means that the memory is exhausted. Here is a crude dump of the exception that I was trying to build:");
+    fprintf(stderr, "%s:%s(%d) [%s:%d] %s", e->host,e->procname,e->pid, e->file,e->line,e->msg);
+    fprintf(stderr, "Bailing out now since there is nothing I can do without a decent amount of memory. Please go fix the memleaks\n");
+    exit(1);
+  }
 }
 
 
@@ -86,8 +92,7 @@ void xbt_ex_setup_backtrace(xbt_ex_t * e)
         char *data;
 
         xbt_dynar_foreach(path, cpt, data) {
-          if (binary_name)
-            free(binary_name);
+          free(binary_name);
           binary_name = bprintf("%s/%s", data, xbt_binary_name);
           if (!stat(binary_name, &stat_buf)) {
             /* Found. */