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

From: Bruno Barbier <[email-masked]>
Date: Wed, 17 Apr 2024 18:05:45 +0200

Hi,

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).

Best,

Bruno

PS: Sorry about the other email on the wrong bug number.  Copy/pasting
the report and updating the text wasn't enough, probably some buffer
local variables or some text properties.  I hope this one follow the
correct path.

In GNU Emacs 30.0.50 (build 1, x86_64-pc-linux-gnu, X toolkit, cairo
 version 1.18.0) of 2024-04-17 built on keynux
Windowing system distributor 'The X.Org Foundation', version 11.0.12101011
System Description: Gentoo Linux

Configured using:
 'configure --prefix=/home/bruno/local --with-x-toolkit=lucid
 --without-toolkit-scroll-bars --without-tree-sitter
 --without-native-compilation --without-modules --without-xwidgets
 --without-threads --without-pop --without-mailutils
 --without-compress-install --without-hesiod --without-gameuser
 --without-lcms2 --without-wide-int --without-kerberos
 --without-kerberos5 --with-sound=no --without-ns --without-gsettings
 --without-gconf --without-libotf --without-m17n-flt
 --with-gif=ifavailable --with-harfbuzz'

Configured features:
ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM HARFBUZZ JPEG LIBXML2
NOTIFY INOTIFY PDUMPER PNG RSVG SECCOMP SQLITE3 TIFF WEBP X11 XDBE XIM
XINPUT2 XPM LUCID ZLIB

Important settings:
  value of $LC_CTYPE: en_US.UTF-8
  value of $LANG: C.UTF8
  locale-coding-system: utf-8-unix

Major mode: Lisp Interaction

Minor modes in effect:
  tooltip-mode: t
  global-eldoc-mode: t
  eldoc-mode: t
  show-paren-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  minibuffer-regexp-mode: t
  line-number-mode: t
  indent-tabs-mode: t
  transient-mark-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug message mailcap yank-media puny dired
dired-loaddefs rfc822 mml mml-sec password-cache epa derived epg rfc6068
epg-config gnus-util text-property-search time-date subr-x mm-decode
mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader
sendmail rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils
warnings icons cl-loaddefs cl-lib rmc iso-transl tooltip cconv eldoc
paren electric uniquify ediff-hook vc-hooks lisp-float-type elisp-mode
mwheel term/x-win x-win term/common-win x-dnd touch-screen tool-bar dnd
fontset image regexp-opt fringe tabulated-list replace newcomment
text-mode lisp-mode prog-mode register page tab-bar menu-bar rfn-eshadow
isearch easymenu timer select scroll-bar mouse jit-lock font-lock syntax
font-core term/tty-colors frame minibuffer nadvice seq simple cl-generic
indonesian philippine cham georgian utf-8-lang misc-lang vietnamese
tibetan thai tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek
romanian slovak czech european ethiopic indian cyrillic chinese
composite emoji-zwj charscript charprop case-table epa-hook
jka-cmpr-hook help abbrev obarray oclosure cl-preloaded button loaddefs
theme-loaddefs faces cus-face macroexp files window text-properties
overlay sha1 md5 base64 format env code-pages mule custom widget keymap
hashtable-print-readable backquote dbusbind inotify dynamic-setting
font-render-setting cairo x-toolkit xinput2 x multi-tty move-toolbar
make-network-process emacs)

Memory information:
((conses 16 40047 17385) (symbols 48 5270 0) (strings 32 13441 1036)
 (string-bytes 1 323186) (vectors 16 9362)
 (vector-slots 8 111771 9938) (floats 8 23 28) (intervals 56 305 0)
 (buffers 984 11))