Subject: bug#70436: 30.0.50; Fail to enter the debugger when using prin1 (instead of cl-prin1)

From: Eli Zaretskii <[email-masked]>
Date: Sat, 20 Apr 2024 11:28:31 +0300

> Cc: [email-masked]
> Date: Sat, 20 Apr 2024 11:24:11 +0300
> From: Eli Zaretskii <[email-masked]>
> 
> > From: Bruno Barbier <[email-masked]>
> > Date: Wed, 17 Apr 2024 15:29:14 +0200
> > 
> > When setting debugger-print-function to prin1, Emacs 30.0.50 may fail
> > to enter the debugger.
> > 
> > Emacs displays something like:
> > 
> >     Entering debugger...
> >     make-text-button: Args out of range: 67, 3000
> > 
> > 
> > The correct behavior is to enter the debugger, with something like this:
> > 
> >     Debugger entered--Lisp error: (wrong-type-argument stringp nil)
> >       #f(compiled-function (&rest args) "Start a program in a subprocess.  ...
> >       ...
> >       make-process(:name "mandatory" :command "ls" :stderr err-buf)
> > 
> > The problem doesn't occur with Emacs 29.3.
> > 
> > To manually reproduce, execute the following code block in a new Emacs
> > (started with '-Q'):
> > 
> >   #+begin_src elisp
> >     (progn 
> >       (setq debugger-print-function 'prin1)
> >       
> >       (defun my-useless-advice (fun &rest args)
> >          (apply fun args))
> > 
> >       (advice-add 'make-process :around #'my-useless-advice)
> > 
> >       (make-process :name "mandatory"
> >                     :command "ls"
> >                     :stderr 'err-buf))
> >   #+end_src
> >   
> > It seems that backtrace.el prints using prin1, but infers where the
> > button should be using cl-prin1.
> > 
> > My personal workaround is to stop setting debugger-print-function to
> > prin1 (I customized it a few years ago because I found that cl-prin1 was
> > really slow at the time, I guess it shouldn't be the case anymore).
> 
> Stefan, is this supposed to be supported?

Btw, if I also set backtrace-print-function to prin1, the above recipe
works as expected.  So maybe we should document that changing
debugger-print-function should also change backtrace-print-function?
Or even use the value of debugger-print-function as the default value
of backtrace-print-function?