From unknown Mon Aug 18 19:34:41 2025 X-Loop: help-debbugs@gnu.org Subject: bug#76786: 31.0.50; condition-case's `debug` causes Emacs to exit when in batch mode Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: monnier@iro.umontreal.ca, bug-gnu-emacs@gnu.org Resent-Date: Thu, 06 Mar 2025 17:21:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 76786 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: 76786@debbugs.gnu.org Cc: monnier@iro.umontreal.ca X-Debbugs-Original-To: bug-gnu-emacs@gnu.org X-Debbugs-Original-Xcc: monnier@iro.umontreal.ca Received: via spool by submit@debbugs.gnu.org id=B.174128164326396 (code B ref -1); Thu, 06 Mar 2025 17:21:02 +0000 Received: (at submit) by debbugs.gnu.org; 6 Mar 2025 17:20:43 +0000 Received: from localhost ([127.0.0.1]:45206 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tqEtm-0006rg-SL for submit@debbugs.gnu.org; Thu, 06 Mar 2025 12:20:43 -0500 Received: from lists.gnu.org ([2001:470:142::17]:40164) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1tqEtk-0006rT-UE for submit@debbugs.gnu.org; Thu, 06 Mar 2025 12:20:41 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tqEtf-000416-EA for bug-gnu-emacs@gnu.org; Thu, 06 Mar 2025 12:20:35 -0500 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tqEtd-00022l-S0 for bug-gnu-emacs@gnu.org; Thu, 06 Mar 2025 12:20:35 -0500 Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id BB14444305D for ; Thu, 6 Mar 2025 12:20:30 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1741281629; bh=gZicm9NlUH3viSHMOTJHskxTkqdTpMit5nRJbaKTId4=; h=From:To:Subject:Date:From; b=EsLBwrJUPjF9lwDg83XBtNbHNNbUn6swL7EEI1g1WvI9/VgvvHhBq2NRrupkmbXLK oZ72qA/eiUbQgGKt/XlgDu9GMVXEcxwIEkML24IUeZmE65ntIAhzrFq67uqfHIAMj/ KkQjKQ08MMc5+Zc7i5ZPJjZKAPCakLC931ZIvDndPP3I59+tCWKVil/rkiWuVC+gyE QHUvfQb1I2afDXi4Gg+7V6e3cH2Omfkrc8AqDxVyuGEXg8XS915zo2RqoBa7YDigGP ThuegtX8a0OYGFKcQeQUP4bxOTnEwzMJKTlmIZLxFH0ACo/cKi4I63/D/ViMG51mvP 4b5YJ4eFW0Otg== Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id D0AE444304C for ; Thu, 6 Mar 2025 12:20:29 -0500 (EST) Received: from alfajor (unknown [104.247.242.5]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id B1F25120497 for ; Thu, 6 Mar 2025 12:20:29 -0500 (EST) From: Stefan Monnier Message-ID: Date: Thu, 06 Mar 2025 12:20:28 -0500 MIME-Version: 1.0 Content-Type: text/plain X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP AWL -0.377 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from domain X-SPAM-LEVEL: Received-SPF: pass client-ip=132.204.25.50; envelope-from=monnier@iro.umontreal.ca; helo=mailscanner.iro.umontreal.ca X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Package: Emacs Version: 31.0.50 % /usr/bin/emacs -Q --batch --eval '(setq debug-on-error t)' --eval '(progn (with-demoted-errors "A %S" (error "foo")) (message "B bar"))' Debugger entered--Lisp error: (error "foo") error("foo") (condition-case err (error "foo") ((debug error) (message "A %S" err) nil)) (condition-case-unless-debug err (error "foo") (error (message "A %S" err) nil)) (with-demoted-errors "A %S" (error "foo")) (progn (with-demoted-errors "A %S" (error "foo")) (message "B bar")) eval((progn (with-demoted-errors "A %S" (error "foo")) (message "B bar")) t) command-line-1(("--eval" "(setq debug-on-error t)" "--eval" "(progn (with-demoted-errors \"A %S\" (error \"foo\")) (message \"B bar\"))")) command-line() normal-top-level() % I'm happy to see a backtrace, but I should *also* see the A foo B bar messages that I get to see when running this code without `--batch`. Stefan From unknown Mon Aug 18 19:34:41 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.505 (Entity 5.505) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: Stefan Monnier Subject: bug#76786: closed (Re: bug#76786: 31.0.50; condition-case's `debug` causes Emacs to exit when in batch mode) Message-ID: References: X-Gnu-PR-Message: they-closed 76786 X-Gnu-PR-Package: emacs Reply-To: 76786@debbugs.gnu.org Date: Thu, 06 Mar 2025 18:08:02 +0000 Content-Type: multipart/mixed; boundary="----------=_1741284482-2467-1" This is a multi-part message in MIME format... ------------=_1741284482-2467-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #76786: 31.0.50; condition-case's `debug` causes Emacs to exit when in batc= h 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 76786@debbugs.gnu.org. --=20 76786: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D76786 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1741284482-2467-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 76786-done) by debbugs.gnu.org; 6 Mar 2025 18:07:15 +0000 Received: from localhost ([127.0.0.1]:45352 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tqFcl-0000ce-9r for submit@debbugs.gnu.org; Thu, 06 Mar 2025 13:07:15 -0500 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:32676) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1tqFcd-0000bx-F2 for 76786-done@debbugs.gnu.org; Thu, 06 Mar 2025 13:07:04 -0500 Received: from pmg1.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 27C94100066; Thu, 6 Mar 2025 13:06:56 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1741284415; bh=dCXn/AE4Yc2QEW0tUA6sP1guTtO19TS++r/Iq3ze0xM=; h=From:To:Subject:In-Reply-To:References:Date:From; b=ebOra2crvf6H/34BgXTO+3FrVvONSzjqpvRC/CjZq37THSpBzWVhYZiUPNuruFCKh eBenRtToSn4b1HQmz5KqCpF4M8oiAEbuIJJq7/hvaaEw/4Nz+QORtoAUkBULhrohy+ /xDNLIfMELno5gqpWmKx/VKY/rqTvwisYEVx//PH7Jkw1EdlB9oMTsHvPTdkx86OId dLzkRRXHmw4ZbKGmNKUhiYhvQCWHIyWoiZZucyxJEitKFoE9pVQ03xvtA7DTv1xU0E LK2MdQpi8v+01HnwTgj2gUwFaX2gDwpPSM3MJJxCGHfRPjM3BSah67soYAS2tOMbPo wSdIEA6n0w7YQ== Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 6B3AE100034; Thu, 6 Mar 2025 13:06:55 -0500 (EST) Received: from alfajor (unknown [104.247.242.5]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 487391200EB; Thu, 6 Mar 2025 13:06:55 -0500 (EST) From: Stefan Monnier To: 76786-done@debbugs.gnu.org Subject: Re: bug#76786: 31.0.50; condition-case's `debug` causes Emacs to exit when in batch mode In-Reply-To: Message-ID: References: Date: Thu, 06 Mar 2025 13:06:54 -0500 User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP AWL -0.236 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from domain X-SPAM-LEVEL: X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 76786-done X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) I pushed the fix below to `master`. It took me a while to find the place where we short-circuited the normal processing, to be honest (it was in `debug`). And digging into its history doesn't completely explain why it's ever been there, but I think it explains why it wasn't harmful back then (`signal_or_quit` would have done the same anyway). Stefan diff --git a/lisp/emacs-lisp/debug.el b/lisp/emacs-lisp/debug.el index 0ca3a0f931c..f8af6eafa32 100644 --- a/lisp/emacs-lisp/debug.el +++ b/lisp/emacs-lisp/debug.el @@ -253,11 +253,11 @@ debug ;; Place an extra debug-on-exit for macro's. (when (eq 'lambda (car-safe (cadr (backtrace-frame 1 base)))) (backtrace-debug 2 t base)))) - (with-current-buffer debugger-buffer - (unless (derived-mode-p 'debugger-mode) - (debugger-mode)) - (debugger-setup-buffer debugger-args) - (when non-interactive-frame + (set-buffer debugger-buffer) + (unless (derived-mode-p 'debugger-mode) + (debugger-mode)) + (debugger-setup-buffer debugger-args) + (if non-interactive-frame ;; If the backtrace is long, save the beginning ;; and the end, but discard the middle. (let ((inhibit-read-only t)) @@ -269,9 +269,8 @@ (goto-char (point-max)) (forward-line (- (/ debugger-batch-max-lines 2))) (delete-region middlestart (point))) - (insert "...\n"))) - (message "%s" (buffer-string)) - (kill-emacs -1))) + (insert "...\n")) + (message "%s" (buffer-string))) (pop-to-buffer debugger-buffer `((display-buffer-reuse-window @@ -300,7 +299,7 @@ (message "") ;; Make sure we unbind buffer-read-only in the right buffer. (save-excursion - (recursive-edit)))) + (recursive-edit))))) (when (and (window-live-p debugger-window) (eq (window-buffer debugger-window) debugger-buffer)) ;; Record height of debugger window. ------------=_1741284482-2467-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 6 Mar 2025 17:20:43 +0000 Received: from localhost ([127.0.0.1]:45206 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tqEtm-0006rg-SL for submit@debbugs.gnu.org; Thu, 06 Mar 2025 12:20:43 -0500 Received: from lists.gnu.org ([2001:470:142::17]:40164) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1tqEtk-0006rT-UE for submit@debbugs.gnu.org; Thu, 06 Mar 2025 12:20:41 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tqEtf-000416-EA for bug-gnu-emacs@gnu.org; Thu, 06 Mar 2025 12:20:35 -0500 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tqEtd-00022l-S0 for bug-gnu-emacs@gnu.org; Thu, 06 Mar 2025 12:20:35 -0500 Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id BB14444305D for ; Thu, 6 Mar 2025 12:20:30 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1741281629; bh=gZicm9NlUH3viSHMOTJHskxTkqdTpMit5nRJbaKTId4=; h=From:To:Subject:Date:From; b=EsLBwrJUPjF9lwDg83XBtNbHNNbUn6swL7EEI1g1WvI9/VgvvHhBq2NRrupkmbXLK oZ72qA/eiUbQgGKt/XlgDu9GMVXEcxwIEkML24IUeZmE65ntIAhzrFq67uqfHIAMj/ KkQjKQ08MMc5+Zc7i5ZPJjZKAPCakLC931ZIvDndPP3I59+tCWKVil/rkiWuVC+gyE QHUvfQb1I2afDXi4Gg+7V6e3cH2Omfkrc8AqDxVyuGEXg8XS915zo2RqoBa7YDigGP ThuegtX8a0OYGFKcQeQUP4bxOTnEwzMJKTlmIZLxFH0ACo/cKi4I63/D/ViMG51mvP 4b5YJ4eFW0Otg== Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id D0AE444304C for ; Thu, 6 Mar 2025 12:20:29 -0500 (EST) Received: from alfajor (unknown [104.247.242.5]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id B1F25120497 for ; Thu, 6 Mar 2025 12:20:29 -0500 (EST) From: Stefan Monnier To: bug-gnu-emacs@gnu.org Subject: 31.0.50; condition-case's `debug` causes Emacs to exit when in batch mode Message-ID: X-Debbugs-Cc: monnier@iro.umontreal.ca Date: Thu, 06 Mar 2025 12:20:28 -0500 MIME-Version: 1.0 Content-Type: text/plain X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP AWL -0.377 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from domain X-SPAM-LEVEL: Received-SPF: pass client-ip=132.204.25.50; envelope-from=monnier@iro.umontreal.ca; helo=mailscanner.iro.umontreal.ca X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Package: Emacs Version: 31.0.50 % /usr/bin/emacs -Q --batch --eval '(setq debug-on-error t)' --eval '(progn (with-demoted-errors "A %S" (error "foo")) (message "B bar"))' Debugger entered--Lisp error: (error "foo") error("foo") (condition-case err (error "foo") ((debug error) (message "A %S" err) nil)) (condition-case-unless-debug err (error "foo") (error (message "A %S" err) nil)) (with-demoted-errors "A %S" (error "foo")) (progn (with-demoted-errors "A %S" (error "foo")) (message "B bar")) eval((progn (with-demoted-errors "A %S" (error "foo")) (message "B bar")) t) command-line-1(("--eval" "(setq debug-on-error t)" "--eval" "(progn (with-demoted-errors \"A %S\" (error \"foo\")) (message \"B bar\"))")) command-line() normal-top-level() % I'm happy to see a backtrace, but I should *also* see the A foo B bar messages that I get to see when running this code without `--batch`. Stefan ------------=_1741284482-2467-1--