GNU bug report logs -
#76787
31.0.50; Double backtrace in batch mode
Previous Next
Reported by: Stefan Monnier <monnier <at> iro.umontreal.ca>
Date: Thu, 6 Mar 2025 17:24:02 UTC
Severity: normal
Found in version 31.0.50
Done: Stefan Monnier <monnier <at> iro.umontreal.ca>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
[Message part 1 (text/plain, inline)]
Your bug report
#76787: 31.0.50; Double backtrace in batch mode
which was filed against the emacs package, has been closed.
The explanation is attached below, along with your original report.
If you require more details, please reply to 76787 <at> debbugs.gnu.org.
--
76787: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=76787
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
> I think I'm in part to blame for this one. It seems that one of them
> comes from the "normal" debugger and the other from
> `debug-early--handler`.
Rather than try and figure out how to coordinate the two places so they
don't both call a debugger, I generalized the
`debugger--last-error` mechanism with the patch below.
Stefan
diff --git a/lisp/emacs-lisp/debug-early.el b/lisp/emacs-lisp/debug-early.el
index 48b71e7f9f0..e63edb19328 100644
--- a/lisp/emacs-lisp/debug-early.el
+++ b/lisp/emacs-lisp/debug-early.el
@@ -36,6 +36,8 @@
;; For bootstrap reasons, we cannot use any macros here since they're
;; not defined yet.
+(defvar debugger--last-error nil)
+
(defalias 'debug-early-backtrace
#'(lambda (&optional base)
"Print a trace of Lisp function calls currently active.
@@ -76,15 +78,19 @@ 'debug-early-backtrace
(setq args (cdr args)))
(princ " ")))
(princ ")\n"))))
- base))))
+ base))
+ (message "debug-early-backtrace...done")))
(defalias 'debug--early
#'(lambda (error base)
- (princ "\nError: ")
- (prin1 (car error)) ; The error symbol.
- (princ " ")
- (prin1 (cdr error)) ; The error data.
- (debug-early-backtrace base)))
+ (if (eq error debugger--last-error) nil
+ (setq debugger--last-error nil)
+ (princ "\nError: ")
+ (prin1 (car error)) ; The error symbol.
+ (princ " ")
+ (prin1 (cdr error)) ; The error data.
+ (prog1 (debug-early-backtrace base)
+ (setq debugger--last-error error)))))
(defalias 'debug-early ;Called from C.
#'(lambda (&rest args)
diff --git a/lisp/emacs-lisp/debug.el b/lisp/emacs-lisp/debug.el
index f8af6eafa32..c1aaa1ac623 100644
--- a/lisp/emacs-lisp/debug.el
+++ b/lisp/emacs-lisp/debug.el
@@ -153,8 +153,6 @@ debugger--restore-buffer-state
(insert (debugger--buffer-state-content state)))
(goto-char (debugger--buffer-state-pos state)))
-(defvar debugger--last-error nil)
-
(defun debugger--duplicate-p (args)
(pcase args
(`(error ,err . ,_) (and (consp err) (eq err debugger--last-error)))))
[Message part 3 (message/rfc822, inline)]
Package: Emacs
Version: 31.0.50
Emacs in batch mode sometimes shows twice the same backtrace:
% /usr/bin/emacs -Q --batch --eval '(setq debug-on-error t)' --eval '(error "foo")'
Error: error ("foo")
error("foo")
eval((error "foo") t)
command-line-1(("--eval" "(setq debug-on-error t)" "--eval" "(error \"foo\")"))
command-line()
normal-top-level()
Debugger entered--Lisp error: (error "foo")
error("foo")
eval((error "foo") t)
command-line-1(("--eval" "(setq debug-on-error t)" "--eval" "(error \"foo\")"))
command-line()
normal-top-level()
%
I think I'm in part to blame for this one. It seems that one of them
comes from the "normal" debugger and the other from
`debug-early--handler`.
Stefan
This bug report was last modified 133 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.