Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
more informative error messages on errors within mmalloc
authorMartin Quinson <mquinson@debian.org>
Tue, 19 Apr 2011 09:49:42 +0000 (11:49 +0200)
committerMartin Quinson <mquinson@debian.org>
Tue, 19 Apr 2011 09:50:22 +0000 (11:50 +0200)
src/xbt/mmalloc/attach.c
src/xbt/mmalloc/mm_legacy.c

index 7963a46..bd151db 100644 (file)
@@ -131,7 +131,7 @@ void *mmalloc_attach(int fd, void *baseaddr)
   if ((mbase = mdp->morecore(mdp, sizeof(mtemp))) != NULL) {
     memcpy(mbase, mdp, sizeof(mtemp));
   } else {
-    abort();
+    THROWF(system_error,0,"morecore failed to get some memory!");
   }
 
   /* Add the new heap to the linked list of heaps attached by mmalloc */  
index 4d46fd6..e9fcb20 100644 (file)
@@ -143,13 +143,15 @@ static void mmalloc_fork_child(void)
 /* Initialize the default malloc descriptor. */
 void mmalloc_preinit(void)
 {
+  int res;
   if (!__mmalloc_default_mdp) {
     __mmalloc_default_mdp =
         mmalloc_attach(-1, (char *) sbrk(0) + HEAP_OFFSET);
     /* Fixme? only the default mdp in protected against forks */
-    if (xbt_os_thread_atfork(mmalloc_fork_prepare,
-                             mmalloc_fork_parent, mmalloc_fork_child) != 0)
-      abort();
+    res = xbt_os_thread_atfork(mmalloc_fork_prepare,
+                              mmalloc_fork_parent, mmalloc_fork_child);
+    if (res != 0)
+      THROWF(system_error,0,"xbt_os_thread_atfork() failed: return value %d",res);
   }
   xbt_assert(__mmalloc_default_mdp != NULL);
 }