GNU bug report logs - #34462
27.0.50; package.el breakage when features are loaded in after-init-hook

Previous Next

Package: emacs;

Reported by: Steve Purcell <steve <at> sanityinc.com>

Date: Tue, 12 Feb 2019 20:05:02 UTC

Severity: normal

Found in version 27.0.50

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

Bug is archived. No further changes may be made.

Full log


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

From: Dmitry Alexandrov <321942 <at> gmail.com>
To: Steve Purcell <steve <at> sanityinc.com>
Cc: 34462 <at> debbugs.gnu.org
Subject: Re: bug#34462: 27.0.50;
 package.el breakage when features are loaded in after-init-hook
Date: Wed, 13 Feb 2019 11:06:01 +0300
[Message part 1 (text/plain, inline)]
Steve Purcell <steve <at> sanityinc.com> wrote:
> Given an init.el snippet like:
>
>     (add-hook 'after-init-hook
>               (lambda ()
>                 (require 'server)
>                 (unless (server-running-p)
>                   (server-start))))
>
> the `load-history' var will contain an entry with a nil car (as per its
> documentation), inside which the `(require . server)' load will be
> noted.
>
> However, the code in `package--list-loaded-files' unconditionally
> applies `file-name-sans-extension' to the cars of `load-history',
> resulting in errors whenever packages are activated (e.g. upgraded,
> installed).
>
> I believe the correct fix would be simply add a `stringp' test here:
>
> https://github.com/emacs-mirror/emacs/blob/5abaf16ab49b86ca5add981c2ddcaea6db0c8a08/lisp/emacs-lisp/package.el#L759
>
> (Using a nightly Emacs HEAD snapshot from a couple of days ago.)

This is actually not limited to package.el.  E. g. lisp/help-fns.el was also written in assumtion, that cars of elements of ‘load-history’ are always file names:

[Message part 2 (text/x-emacs-lisp, inline)]
(defun help-fns--autoloaded-p (function file)
  "Return non-nil if FUNCTION has previously been autoloaded.
FILE is the file where FUNCTION was probably defined."
  (let* ((file (file-name-sans-extension (file-truename file)))
	 (load-hist load-history)
	 (target (cons t function))
	 found)
    (while (and load-hist (not found))
      (and (caar load-hist)
	   (equal (file-name-sans-extension (caar load-hist)) file)
	   (setq found (member target (cdar load-hist))))
      (setq load-hist (cdr load-hist)))
    found))
[Message part 3 (text/plain, inline)]
Moreover:

$ emacs -Q
<f1> f emacs-lisp-mode RET

[Message part 4 (text/x-backtrace, inline)]
Debugger entered--Lisp error: (wrong-type-argument stringp (require . elec-pair))
  file-name-nondirectory((require . elec-pair))
  file-name-sans-extension((require . elec-pair))
  help-fns--autoloaded-p(emacs-lisp-mode "/var/share/pub/src/emacs.~21eef9fa7f~/lisp/progmod...")
  help-fns-function-description-header(emacs-lisp-mode)
  describe-function-1(emacs-lisp-mode)
  describe-function(emacs-lisp-mode)
  funcall-interactively(describe-function emacs-lisp-mode)
  call-interactively(describe-function nil nil)
  command-execute(describe-function)
[Message part 5 (text/plain, inline)]
So something forgot to put there even nil, but started the list right with ENTRIES.
[signature.asc (application/pgp-signature, inline)]

This bug report was last modified 6 years and 80 days ago.

Previous Next


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