GNU bug report logs - #63881
29.0.91; apropos-documentation fails when load-history contains element whose CAR is nil

Previous Next

Package: emacs;

Reported by: Visuwesh <visuweshm <at> gmail.com>

Date: Sun, 4 Jun 2023 03:08:01 UTC

Severity: normal

Found in version 29.0.91

Done: Eli Zaretskii <eliz <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Eli Zaretskii <eliz <at> gnu.org>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 63881 <at> debbugs.gnu.org, visuweshm <at> gmail.com
Subject: bug#63881: 29.0.91; apropos-documentation fails when load-history contains element whose CAR is nil
Date: Sat, 10 Jun 2023 12:25:49 +0300
> Cc: 63881 <at> debbugs.gnu.org
> Date: Sun, 04 Jun 2023 08:31:58 +0300
> From: Eli Zaretskii <eliz <at> gnu.org>
> 
> > From: Visuwesh <visuweshm <at> gmail.com>
> > Date: Sun, 04 Jun 2023 08:37:08 +0530
> > 
> > 
> > As per (info "(elisp) Where Defined"), load-history may contain an
> > element whose CAR is nil if eval-buffer was used to evaluate a defun
> > in a non-file-visiting buffer.
> > 
> > After such an entry is added to load-history, apropos-documentation
> > fails with the backtrace at end.
> 
> How did you add such an entry to load-history?  IOW, is there a
> real-life use case where this happens?
> 
> > To reproduce the issue,
> > 
> >     1. emacs -Q
> >     2. Insert (defun test () t)
> >     3. M-x eval-buffer RET
> >     4. Confirm that a nil entry is present in load-history by evaluating
> >        (alist-get nil load-history 'none)
> >     5. C-h d any RET
> > 
> > The problem lies in apropos--map-preloaded-atoms in the part
> > 
> >     (dolist (x load-history)
> >       (when (string-match preloaded-regexp (car x))
> >                                            ^^^^^^^^
> >         (dolist (def (cdr x))
> >           (cond
> >            ((symbolp def) (funcall f def))
> >            ((eq 'defun (car-safe def)) (funcall f (cdr def)))))))))
> > 
> > 
> > ----
> > 
> > 
> > Debugger entered--Lisp error: (wrong-type-argument stringp nil)
> >   string-match("\\`/home/viz/lib/ports/emacs/lisp/\\(?:abbrev\\|b\\(?:..." nil)
> >   (if (string-match preloaded-regexp (car x)) (progn (let ((tail (cdr x))) (while tail (let ((def (car tail))) (cond ((symbolp def) (funcall f def)) ((eq ... ...) (funcall f ...))) (setq tail (cdr tail)))))))

Stefan, does the below look good for emacs-29?

diff --git a/lisp/apropos.el b/lisp/apropos.el
index 5d7fe69..c9551b0 100644
--- a/lisp/apropos.el
+++ b/lisp/apropos.el
@@ -900,7 +900,8 @@ apropos--map-preloaded-atoms
     ;; state of the `obarray' when we dumped, which we may also be able to
     ;; use in `bytecomp' to provide a clean initial environment?)
     (dolist (x load-history)
-      (when (string-match preloaded-regexp (car x))
+      (when (let ((elt (car x)))
+              (and (stringp elt) (string-match preloaded-regexp elt)))
         (dolist (def (cdr x))
           (cond
            ((symbolp def) (funcall f def))




This bug report was last modified 1 year and 348 days ago.

Previous Next


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