diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 10 | ||||
| -rw-r--r-- | src/emacs.c | 2 | ||||
| -rw-r--r-- | src/sysdep.c | 12 |
3 files changed, 23 insertions, 1 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 6ef5746daa2..1f0781fef10 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,13 @@ | |||
| 1 | 2015-02-25 Paul Eggert <eggert@cs.ucla.edu> | ||
| 2 | |||
| 3 | Backtrace after malloc arena is corrupted | ||
| 4 | Without this change, if the malloc arena is corrupted and then | ||
| 5 | 'backtrace' is called, the backtrace can crash because 'backtrace' | ||
| 6 | calls 'malloc'. For more, please see: | ||
| 7 | https://sourceware.org/ml/libc-alpha/2015-02/msg00678.html | ||
| 8 | * emacs.c (main): Initialize tables used by 'backtrace'. | ||
| 9 | * sysdep.c (emacs_backtrace): Document the newly used part of the API. | ||
| 10 | |||
| 1 | 2015-02-22 Jan Djärv <jan.h.d@swipnet.se> | 11 | 2015-02-22 Jan Djärv <jan.h.d@swipnet.se> |
| 2 | 12 | ||
| 3 | * nsfns.m (Fx_frame_geometry): New function. | 13 | * nsfns.m (Fx_frame_geometry): New function. |
diff --git a/src/emacs.c b/src/emacs.c index 4a6d6badf28..c2b698ba50b 100644 --- a/src/emacs.c +++ b/src/emacs.c | |||
| @@ -884,6 +884,8 @@ main (int argc, char **argv) | |||
| 884 | 884 | ||
| 885 | clearerr (stdin); | 885 | clearerr (stdin); |
| 886 | 886 | ||
| 887 | emacs_backtrace (-1); | ||
| 888 | |||
| 887 | #if !defined SYSTEM_MALLOC && !defined HYBRID_MALLOC | 889 | #if !defined SYSTEM_MALLOC && !defined HYBRID_MALLOC |
| 888 | /* Arrange to get warning messages as memory fills up. */ | 890 | /* Arrange to get warning messages as memory fills up. */ |
| 889 | memory_warnings (0, malloc_warning); | 891 | memory_warnings (0, malloc_warning); |
diff --git a/src/sysdep.c b/src/sysdep.c index a2bda96192f..cb361ec2dc5 100644 --- a/src/sysdep.c +++ b/src/sysdep.c | |||
| @@ -2147,7 +2147,17 @@ snprintf (char *buf, size_t bufsize, char const *format, ...) | |||
| 2147 | /* If a backtrace is available, output the top lines of it to stderr. | 2147 | /* If a backtrace is available, output the top lines of it to stderr. |
| 2148 | Do not output more than BACKTRACE_LIMIT or BACKTRACE_LIMIT_MAX lines. | 2148 | Do not output more than BACKTRACE_LIMIT or BACKTRACE_LIMIT_MAX lines. |
| 2149 | This function may be called from a signal handler, so it should | 2149 | This function may be called from a signal handler, so it should |
| 2150 | not invoke async-unsafe functions like malloc. */ | 2150 | not invoke async-unsafe functions like malloc. |
| 2151 | |||
| 2152 | If BACKTRACE_LIMIT is -1, initialize tables that 'backtrace' uses | ||
| 2153 | but do not output anything. This avoids some problems that can | ||
| 2154 | otherwise occur if the malloc arena is corrupted before 'backtrace' | ||
| 2155 | is called, since 'backtrace' may call malloc if the tables are not | ||
| 2156 | initialized. | ||
| 2157 | |||
| 2158 | If the static variable THREAD_BACKTRACE_NPOINTERS is nonzero, a | ||
| 2159 | fatal error has occurred in some other thread; generate a thread | ||
| 2160 | backtrace instead, ignoring BACKTRACE_LIMIT. */ | ||
| 2151 | void | 2161 | void |
| 2152 | emacs_backtrace (int backtrace_limit) | 2162 | emacs_backtrace (int backtrace_limit) |
| 2153 | { | 2163 | { |