diff options
| author | Eli Zaretskii | 2019-02-28 21:16:10 +0200 |
|---|---|---|
| committer | Eli Zaretskii | 2019-02-28 21:16:10 +0200 |
| commit | 5d60229bf1a9a496102fc2a3ef9e57dcce7bef10 (patch) | |
| tree | d74d82b9bcb1b1bcfa589957ea76e6672e952ef2 /src | |
| parent | 0a5212b99666b9ba0543a62cdbb12ee0685820f3 (diff) | |
| download | emacs-5d60229bf1a9a496102fc2a3ef9e57dcce7bef10.tar.gz emacs-5d60229bf1a9a496102fc2a3ef9e57dcce7bef10.zip | |
Avoid rare crashes in xbacktrace
* src/eval.c (backtrace_thread_p, backtrace_top): Don't
segfault in "xbacktrace" if called before the specpdl
machinery is initialized in pdumped Emacs.
Diffstat (limited to 'src')
| -rw-r--r-- | src/eval.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/eval.c b/src/eval.c index bf16a709b15..e162725f03d 100644 --- a/src/eval.c +++ b/src/eval.c | |||
| @@ -179,7 +179,7 @@ set_backtrace_debug_on_exit (union specbinding *pdl, bool doe) | |||
| 179 | 179 | ||
| 180 | bool | 180 | bool |
| 181 | backtrace_p (union specbinding *pdl) | 181 | backtrace_p (union specbinding *pdl) |
| 182 | { return pdl >= specpdl; } | 182 | { return specpdl ? pdl >= specpdl : false; } |
| 183 | 183 | ||
| 184 | static bool | 184 | static bool |
| 185 | backtrace_thread_p (struct thread_state *tstate, union specbinding *pdl) | 185 | backtrace_thread_p (struct thread_state *tstate, union specbinding *pdl) |
| @@ -188,6 +188,12 @@ backtrace_thread_p (struct thread_state *tstate, union specbinding *pdl) | |||
| 188 | union specbinding * | 188 | union specbinding * |
| 189 | backtrace_top (void) | 189 | backtrace_top (void) |
| 190 | { | 190 | { |
| 191 | /* This is so "xbacktrace" doesn't crash in pdumped Emacs if they | ||
| 192 | invoke the command before init_eval_once_for_pdumper initializes | ||
| 193 | specpdl machinery. See also backtrace_p above. */ | ||
| 194 | if (!specpdl) | ||
| 195 | return NULL; | ||
| 196 | |||
| 191 | union specbinding *pdl = specpdl_ptr - 1; | 197 | union specbinding *pdl = specpdl_ptr - 1; |
| 192 | while (backtrace_p (pdl) && pdl->kind != SPECPDL_BACKTRACE) | 198 | while (backtrace_p (pdl) && pdl->kind != SPECPDL_BACKTRACE) |
| 193 | pdl--; | 199 | pdl--; |