From 54b94af19d371f55f8a5f60352a14791de0d3e97 Mon Sep 17 00:00:00 2001 From: Zach Shaftel Date: Wed, 22 Jul 2020 19:55:15 -0400 Subject: [PATCH] Only store offset when executing bytecode * src/eval.c (record_in_backtrace): Use 'backtrace_top' instead of 'backtrace_next', and check that 'backtrace_byte_offset' > 0 before calling it, so the specbinding stack isn't scanned just to store an invalid offset. --- src/eval.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/eval.c b/src/eval.c index 73ad3d3bc90..b9640f6ab7a 100644 --- a/src/eval.c +++ b/src/eval.c @@ -2154,10 +2154,11 @@ record_in_backtrace (Lisp_Object function, Lisp_Object *args, ptrdiff_t nargs) specpdl_ptr->bt.function = function; current_thread->stack_top = specpdl_ptr->bt.args = args; specpdl_ptr->bt.nargs = nargs; - union specbinding *nxt = specpdl_ptr; - nxt = backtrace_next(nxt); - if (nxt->kind == SPECPDL_BACKTRACE) - nxt->bt.bytecode_offset = backtrace_byte_offset; + if (backtrace_byte_offset > 0) { + union specbinding *nxt = backtrace_top (); + if (backtrace_p (nxt) && nxt->kind == SPECPDL_BACKTRACE) + nxt->bt.bytecode_offset = backtrace_byte_offset; + } grow_specpdl (); return count; -- 2.39.2