]> git.eshelyaron.com Git - emacs.git/commitdiff
Avoid rare crashes in xbacktrace
authorEli Zaretskii <eliz@gnu.org>
Thu, 28 Feb 2019 19:16:10 +0000 (21:16 +0200)
committerEli Zaretskii <eliz@gnu.org>
Thu, 28 Feb 2019 19:16:10 +0000 (21:16 +0200)
* src/eval.c (backtrace_thread_p, backtrace_top): Don't
segfault in "xbacktrace" if called before the specpdl
machinery is initialized in pdumped Emacs.

src/eval.c

index bf16a709b1511e91b5539c40f9a9a78af48207a3..e162725f03db9ca4b09bc0bd0cf6dd2b808ab67d 100644 (file)
@@ -179,7 +179,7 @@ set_backtrace_debug_on_exit (union specbinding *pdl, bool doe)
 
 bool
 backtrace_p (union specbinding *pdl)
-{ return pdl >= specpdl; }
+{ return specpdl ? pdl >= specpdl : false; }
 
 static bool
 backtrace_thread_p (struct thread_state *tstate, union specbinding *pdl)
@@ -188,6 +188,12 @@ backtrace_thread_p (struct thread_state *tstate, union specbinding *pdl)
 union specbinding *
 backtrace_top (void)
 {
+  /* This is so "xbacktrace" doesn't crash in pdumped Emacs if they
+     invoke the command before init_eval_once_for_pdumper initializes
+     specpdl machinery.  See also backtrace_p above.  */
+  if (!specpdl)
+    return NULL;
+
   union specbinding *pdl = specpdl_ptr - 1;
   while (backtrace_p (pdl) && pdl->kind != SPECPDL_BACKTRACE)
     pdl--;