mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-06 06:20:55 -08:00
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.
This commit is contained in:
parent
c803af788d
commit
b4788b9394
1 changed files with 5 additions and 1 deletions
|
|
@ -20,6 +20,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
|
||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <limits.h> /* For CHAR_BIT. */
|
#include <limits.h> /* For CHAR_BIT. */
|
||||||
#include <signal.h> /* For SIGABRT, SIGDANGER. */
|
#include <signal.h> /* 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
|
# ifndef XMALLOC_OVERRUN_CHECK
|
||||||
alloc_unexec_post ();
|
alloc_unexec_post ();
|
||||||
# endif
|
# endif
|
||||||
|
|
@ -174,6 +176,8 @@ alloc_unexec_pre (void)
|
||||||
{
|
{
|
||||||
#ifdef DOUG_LEA_MALLOC
|
#ifdef DOUG_LEA_MALLOC
|
||||||
malloc_state_ptr = malloc_get_state ();
|
malloc_state_ptr = malloc_get_state ();
|
||||||
|
if (!malloc_state_ptr)
|
||||||
|
fatal ("malloc_get_state: %s", strerror (errno));
|
||||||
#endif
|
#endif
|
||||||
#ifdef HYBRID_MALLOC
|
#ifdef HYBRID_MALLOC
|
||||||
bss_sbrk_did_unexec = true;
|
bss_sbrk_did_unexec = true;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue