GNU bug report logs - #38927
[patch] Backtrace printing in non-interactive mode doesn't use cl-prin1 etc.

Previous Next

Package: emacs;

Reported by: Paul Pogonyshev <pogonyshev <at> gmail.com>

Date: Sat, 4 Jan 2020 22:03:01 UTC

Severity: normal

Tags: patch

Done: Stefan Monnier <monnier <at> iro.umontreal.ca>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 38927 in the body.
You can then email your comments to 38927 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#38927; Package emacs. (Sat, 04 Jan 2020 22:03:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Paul Pogonyshev <pogonyshev <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sat, 04 Jan 2020 22:03:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Paul Pogonyshev <pogonyshev <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: [patch] Backtrace printing in non-interactive mode doesn't use
 cl-prin1 etc.
Date: Sat, 4 Jan 2020 23:01:53 +0100
[Message part 1 (text/plain, inline)]
tags

Backtrace printing in batch mode ignores all customizations, at least:
- all `cl-print-object' overrides (`debugger-print-function');
- `print-level', `print-length' and friends;
- `debugger-batch-max-lines'.

The reason is this commit:

7228488effa78dcb75284cb6d247b24804e0e7f5
Author:     Stefan Monnier <monnier <at> iro.umontreal.ca>
AuthorDate: 2018-04-02 00:23:20 -0400
[...]

* lisp/emacs-lisp/debug.el (debug): Don't hang upon error in initial-frame.

[...]
+   ((and (eq t (framep (selected-frame)))
+         (equal "initial_terminal" (terminal-name)))
+    ;; We're in the initial-frame (where `message' just outputs to stdout) so
+    ;; there's no tty or GUI frame to display the backtrace and interact with
+    ;; it: just dump a backtrace to stdout.
+    ;; This happens for example while handling an error in code from
+    ;; early-init.el with --debug-init.
+    (message "Error: %S" args)
[...]

The commit added a "failsafe" mode for (quoting) "initial-frame (where
`message' just outputs to stdout) so there's no tty or GUI frame".
This failsafe mode is also erroneously triggered in batch mode. It was
never meant for it: you can see a couple of uses of `noninteractive'
in the next `cond' branch, but execution now never gets to it.

Patch attached:
- don't use this "failsafe" mode when running non-interactively;
- repair for the latest changes in backtrace generation (apparently,
before the buffer was not read-only);
- repair adjustment for `debugger-batch-max-lines' which didn't make
any sense and didn't achieve what it claimed in the comment.

Paul
[0001-Don-t-apply-the-special-case-to-non-interactive-mode.patch (text/x-patch, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#38927; Package emacs. (Sat, 29 Feb 2020 05:07:02 GMT) Full text and rfc822 format available.

Message #8 received at 38927 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Kangas <stefan <at> marxist.se>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 38927 <at> debbugs.gnu.org, Paul Pogonyshev <pogonyshev <at> gmail.com>
Subject: Re: bug#38927: [patch] Backtrace printing in non-interactive mode
 doesn't use cl-prin1 etc.
Date: Sat, 29 Feb 2020 06:06:23 +0100
Hi Stefan,

Do you have any comments on the below patch?  It seems to relate to a
commit of yours, but has unfortunately not received any reply yet.

Thanks in advance.

Best regards,
Stefan Kangas


Paul Pogonyshev <pogonyshev <at> gmail.com> writes:

> tags
>
> Backtrace printing in batch mode ignores all customizations, at least:
> - all `cl-print-object' overrides (`debugger-print-function');
> - `print-level', `print-length' and friends;
> - `debugger-batch-max-lines'.
>
> The reason is this commit:
>
> 7228488effa78dcb75284cb6d247b24804e0e7f5
> Author:     Stefan Monnier <monnier <at> iro.umontreal.ca>
> AuthorDate: 2018-04-02 00:23:20 -0400
> [...]
>
> * lisp/emacs-lisp/debug.el (debug): Don't hang upon error in initial-frame.
>
> [...]
> +   ((and (eq t (framep (selected-frame)))
> +         (equal "initial_terminal" (terminal-name)))
> +    ;; We're in the initial-frame (where `message' just outputs to stdout) so
> +    ;; there's no tty or GUI frame to display the backtrace and interact with
> +    ;; it: just dump a backtrace to stdout.
> +    ;; This happens for example while handling an error in code from
> +    ;; early-init.el with --debug-init.
> +    (message "Error: %S" args)
> [...]
>
> The commit added a "failsafe" mode for (quoting) "initial-frame (where
> `message' just outputs to stdout) so there's no tty or GUI frame".
> This failsafe mode is also erroneously triggered in batch mode. It was
> never meant for it: you can see a couple of uses of `noninteractive'
> in the next `cond' branch, but execution now never gets to it.
>
> Patch attached:
> - don't use this "failsafe" mode when running non-interactively;
> - repair for the latest changes in backtrace generation (apparently,
> before the buffer was not read-only);
> - repair adjustment for `debugger-batch-max-lines' which didn't make
> any sense and didn't achieve what it claimed in the comment.
>
> Paul
>
> From 180f4a4f771696512af31ded93057713a5507147 Mon Sep 17 00:00:00 2001
> From: Paul Pogonyshev <pogonyshev <at> gmail.com>
> Date: Sat, 4 Jan 2020 22:47:24 +0100
> Subject: [PATCH] Don't apply the special case to non-interactive mode in
>  `debug'
>
> ---
>  lisp/emacs-lisp/debug.el | 25 +++++++++++++------------
>  1 file changed, 13 insertions(+), 12 deletions(-)
>
> diff --git a/lisp/emacs-lisp/debug.el b/lisp/emacs-lisp/debug.el
> index 3df0ba4a65..b6c58b8c7b 100644
> --- a/lisp/emacs-lisp/debug.el
> +++ b/lisp/emacs-lisp/debug.el
> @@ -172,7 +172,8 @@ debug
>     (inhibit-redisplay
>      ;; Don't really try to enter debugger within an eval from redisplay.
>      debugger-value)
> -   ((and (eq t (framep (selected-frame)))
> +   ((and (not noninteractive)
> +         (eq t (framep (selected-frame)))
>           (equal "initial_terminal" (terminal-name)))
>      ;; We're in the initial-frame (where `message' just outputs to stdout) so
>      ;; there's no tty or GUI frame to display the backtrace and interact with
> @@ -246,17 +247,17 @@ debug
>  	        (when noninteractive
>  		  ;; If the backtrace is long, save the beginning
>  		  ;; and the end, but discard the middle.
> -		  (when (> (count-lines (point-min) (point-max))
> -			   debugger-batch-max-lines)
> -		    (goto-char (point-min))
> -		    (forward-line (/ 2 debugger-batch-max-lines))
> -		    (let ((middlestart (point)))
> -		      (goto-char (point-max))
> -		      (forward-line (- (/ 2 debugger-batch-max-lines)
> -				       debugger-batch-max-lines))
> -		      (delete-region middlestart (point)))
> -		    (insert "...\n"))
> -		  (goto-char (point-min))
> +                  (let ((inhibit-read-only t))
> +		    (when (> (count-lines (point-min) (point-max))
> +			     debugger-batch-max-lines)
> +		      (goto-char (point-min))
> +		      (forward-line (/ debugger-batch-max-lines 4))
> +		      (let ((middlestart (point)))
> +		        (goto-char (point-max))
> +		        (forward-line (- (/ 2 debugger-batch-max-lines)
> +				         debugger-batch-max-lines))
> +		        (delete-region middlestart (point)))
> +		      (insert "...\n")))
>  		  (message "%s" (buffer-string))
>  		  (kill-emacs -1)))
>  	      (pop-to-buffer




Reply sent to Stefan Monnier <monnier <at> iro.umontreal.ca>:
You have taken responsibility. (Sat, 29 Feb 2020 14:08:02 GMT) Full text and rfc822 format available.

Notification sent to Paul Pogonyshev <pogonyshev <at> gmail.com>:
bug acknowledged by developer. (Sat, 29 Feb 2020 14:08:02 GMT) Full text and rfc822 format available.

Message #13 received at 38927-done <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Stefan Kangas <stefan <at> marxist.se>
Cc: 38927-done <at> debbugs.gnu.org, Paul Pogonyshev <pogonyshev <at> gmail.com>
Subject: Re: bug#38927: [patch] Backtrace printing in non-interactive mode
 doesn't use cl-prin1 etc.
Date: Sat, 29 Feb 2020 09:07:08 -0500
> Do you have any comments on the below patch?  It seems to relate to a
> commit of yours, but has unfortunately not received any reply yet.

Hmm... looks like the bug tracker was kept out of the discussion.
This has been fixed already by 0223a1577c8999b8ea5eb35f39bc68360cbf5221


        Stefan


> Paul Pogonyshev <pogonyshev <at> gmail.com> writes:
>
>> tags
>>
>> Backtrace printing in batch mode ignores all customizations, at least:
>> - all `cl-print-object' overrides (`debugger-print-function');
>> - `print-level', `print-length' and friends;
>> - `debugger-batch-max-lines'.
>>
>> The reason is this commit:
>>
>> 7228488effa78dcb75284cb6d247b24804e0e7f5
>> Author:     Stefan Monnier <monnier <at> iro.umontreal.ca>
>> AuthorDate: 2018-04-02 00:23:20 -0400
>> [...]
>>
>> * lisp/emacs-lisp/debug.el (debug): Don't hang upon error in initial-frame.
>>
>> [...]
>> +   ((and (eq t (framep (selected-frame)))
>> +         (equal "initial_terminal" (terminal-name)))
>> +    ;; We're in the initial-frame (where `message' just outputs to stdout) so
>> +    ;; there's no tty or GUI frame to display the backtrace and interact with
>> +    ;; it: just dump a backtrace to stdout.
>> +    ;; This happens for example while handling an error in code from
>> +    ;; early-init.el with --debug-init.
>> +    (message "Error: %S" args)
>> [...]
>>
>> The commit added a "failsafe" mode for (quoting) "initial-frame (where
>> `message' just outputs to stdout) so there's no tty or GUI frame".
>> This failsafe mode is also erroneously triggered in batch mode. It was
>> never meant for it: you can see a couple of uses of `noninteractive'
>> in the next `cond' branch, but execution now never gets to it.
>>
>> Patch attached:
>> - don't use this "failsafe" mode when running non-interactively;
>> - repair for the latest changes in backtrace generation (apparently,
>> before the buffer was not read-only);
>> - repair adjustment for `debugger-batch-max-lines' which didn't make
>> any sense and didn't achieve what it claimed in the comment.
>>
>> Paul
>>
>> From 180f4a4f771696512af31ded93057713a5507147 Mon Sep 17 00:00:00 2001
>> From: Paul Pogonyshev <pogonyshev <at> gmail.com>
>> Date: Sat, 4 Jan 2020 22:47:24 +0100
>> Subject: [PATCH] Don't apply the special case to non-interactive mode in
>>  `debug'
>>
>> ---
>>  lisp/emacs-lisp/debug.el | 25 +++++++++++++------------
>>  1 file changed, 13 insertions(+), 12 deletions(-)
>>
>> diff --git a/lisp/emacs-lisp/debug.el b/lisp/emacs-lisp/debug.el
>> index 3df0ba4a65..b6c58b8c7b 100644
>> --- a/lisp/emacs-lisp/debug.el
>> +++ b/lisp/emacs-lisp/debug.el
>> @@ -172,7 +172,8 @@ debug
>>     (inhibit-redisplay
>>      ;; Don't really try to enter debugger within an eval from redisplay.
>>      debugger-value)
>> -   ((and (eq t (framep (selected-frame)))
>> +   ((and (not noninteractive)
>> +         (eq t (framep (selected-frame)))
>>           (equal "initial_terminal" (terminal-name)))
>>      ;; We're in the initial-frame (where `message' just outputs to stdout) so
>>      ;; there's no tty or GUI frame to display the backtrace and interact with
>> @@ -246,17 +247,17 @@ debug
>>  	        (when noninteractive
>>  		  ;; If the backtrace is long, save the beginning
>>  		  ;; and the end, but discard the middle.
>> -		  (when (> (count-lines (point-min) (point-max))
>> -			   debugger-batch-max-lines)
>> -		    (goto-char (point-min))
>> -		    (forward-line (/ 2 debugger-batch-max-lines))
>> -		    (let ((middlestart (point)))
>> -		      (goto-char (point-max))
>> -		      (forward-line (- (/ 2 debugger-batch-max-lines)
>> -				       debugger-batch-max-lines))
>> -		      (delete-region middlestart (point)))
>> -		    (insert "...\n"))
>> -		  (goto-char (point-min))
>> +                  (let ((inhibit-read-only t))
>> +		    (when (> (count-lines (point-min) (point-max))
>> +			     debugger-batch-max-lines)
>> +		      (goto-char (point-min))
>> +		      (forward-line (/ debugger-batch-max-lines 4))
>> +		      (let ((middlestart (point)))
>> +		        (goto-char (point-max))
>> +		        (forward-line (- (/ 2 debugger-batch-max-lines)
>> +				         debugger-batch-max-lines))
>> +		        (delete-region middlestart (point)))
>> +		      (insert "...\n")))
>>  		  (message "%s" (buffer-string))
>>  		  (kill-emacs -1)))
>>  	      (pop-to-buffer





bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sun, 29 Mar 2020 11:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 4 years and 29 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.