diff options
| author | Paul Eggert | 2016-06-10 17:18:24 -0700 |
|---|---|---|
| committer | Paul Eggert | 2016-06-10 17:19:05 -0700 |
| commit | b4788b9394f3c9d50468607cbcf82e9490fa7c1d (patch) | |
| tree | 2a72be3447cb3576f5445dba67d280ae2f6f127d /src | |
| parent | c803af788d4140c7253b1d091e6f7fb63b5a214a (diff) | |
| download | emacs-b4788b9394f3c9d50468607cbcf82e9490fa7c1d.tar.gz emacs-b4788b9394f3c9d50468607cbcf82e9490fa7c1d.zip | |
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.
Diffstat (limited to 'src')
| -rw-r--r-- | src/alloc.c | 6 |
1 files changed, 5 insertions, 1 deletions
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 <http://www.gnu.org/licenses/>. */ | |||
| 20 | 20 | ||
| 21 | #include <config.h> | 21 | #include <config.h> |
| 22 | 22 | ||
| 23 | #include <errno.h> | ||
| 23 | #include <stdio.h> | 24 | #include <stdio.h> |
| 24 | #include <limits.h> /* For CHAR_BIT. */ | 25 | #include <limits.h> /* For CHAR_BIT. */ |
| 25 | #include <signal.h> /* For SIGABRT, SIGDANGER. */ | 26 | #include <signal.h> /* For SIGABRT, SIGDANGER. */ |
| @@ -150,7 +151,8 @@ malloc_initialize_hook (void) | |||
| 150 | } | 151 | } |
| 151 | } | 152 | } |
| 152 | 153 | ||
| 153 | malloc_set_state (malloc_state_ptr); | 154 | if (malloc_set_state (malloc_state_ptr) != 0) |
| 155 | emacs_abort (); | ||
| 154 | # ifndef XMALLOC_OVERRUN_CHECK | 156 | # ifndef XMALLOC_OVERRUN_CHECK |
| 155 | alloc_unexec_post (); | 157 | alloc_unexec_post (); |
| 156 | # endif | 158 | # endif |
| @@ -174,6 +176,8 @@ alloc_unexec_pre (void) | |||
| 174 | { | 176 | { |
| 175 | #ifdef DOUG_LEA_MALLOC | 177 | #ifdef DOUG_LEA_MALLOC |
| 176 | malloc_state_ptr = malloc_get_state (); | 178 | malloc_state_ptr = malloc_get_state (); |
| 179 | if (!malloc_state_ptr) | ||
| 180 | fatal ("malloc_get_state: %s", strerror (errno)); | ||
| 177 | #endif | 181 | #endif |
| 178 | #ifdef HYBRID_MALLOC | 182 | #ifdef HYBRID_MALLOC |
| 179 | bss_sbrk_did_unexec = true; | 183 | bss_sbrk_did_unexec = true; |