From: Paul Eggert Date: Sat, 11 Jun 2016 00:18:24 +0000 (-0700) Subject: Catch malloc_get_state, malloc_set_state failure X-Git-Tag: emacs-26.0.90~1840^2~241 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=b4788b9394f3c9d50468607cbcf82e9490fa7c1d;p=emacs.git Catch malloc_get_state, malloc_set_state failure This should help insulate Emacs better from configuration screwups. Future versions of the GNU C library are planned to deprecate these functions, but will continue to support them in already-built-and-dumped Emacs executables. * src/alloc.c (malloc_initialize_hook) [DOUG_LEA_MALLOC]: Abort if malloc_set_state fails. (alloc_unexec_pre) [DOUG_LEA_MALLOC]: Report malloc_get_state failure, and exit. --- diff --git a/src/alloc.c b/src/alloc.c index 054e1ca23ca..3feed51b1e9 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -20,6 +20,7 @@ along with GNU Emacs. If not, see . */ #include +#include #include #include /* For CHAR_BIT. */ #include /* For SIGABRT, SIGDANGER. */ @@ -150,7 +151,8 @@ malloc_initialize_hook (void) } } - malloc_set_state (malloc_state_ptr); + if (malloc_set_state (malloc_state_ptr) != 0) + emacs_abort (); # ifndef XMALLOC_OVERRUN_CHECK alloc_unexec_post (); # endif @@ -174,6 +176,8 @@ alloc_unexec_pre (void) { #ifdef DOUG_LEA_MALLOC malloc_state_ptr = malloc_get_state (); + if (!malloc_state_ptr) + fatal ("malloc_get_state: %s", strerror (errno)); #endif #ifdef HYBRID_MALLOC bss_sbrk_did_unexec = true;