From 560abd625b757e887c5ee0c7183e9451fd02966a Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Tue, 19 Apr 2011 11:49:42 +0200 Subject: [PATCH] more informative error messages on errors within mmalloc --- src/xbt/mmalloc/attach.c | 2 +- src/xbt/mmalloc/mm_legacy.c | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/xbt/mmalloc/attach.c b/src/xbt/mmalloc/attach.c index 7963a467fd..bd151db9c0 100644 --- a/src/xbt/mmalloc/attach.c +++ b/src/xbt/mmalloc/attach.c @@ -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 */ diff --git a/src/xbt/mmalloc/mm_legacy.c b/src/xbt/mmalloc/mm_legacy.c index 4d46fd6a5d..e9fcb2048b 100644 --- a/src/xbt/mmalloc/mm_legacy.c +++ b/src/xbt/mmalloc/mm_legacy.c @@ -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); } -- 2.20.1