GNU bug report logs - #49746
28.0.50; bytecompilation introduces bug in org-capture with certain template

Previous Next

Package: emacs;

Reported by: Gregor Zattler <telegraph <at> gmx.net>

Date: Tue, 27 Jul 2021 14:00:01 UTC

Severity: normal

Found in version 28.0.50

Done: Mattias Engdegård <mattiase <at> acm.org>

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 49746 in the body.
You can then email your comments to 49746 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#49746; Package emacs. (Tue, 27 Jul 2021 14:00:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Gregor Zattler <telegraph <at> gmx.net>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Tue, 27 Jul 2021 14:00:02 GMT) Full text and rfc822 format available.

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

From: Gregor Zattler <telegraph <at> gmx.net>
To: bug-gnu-emacs <at> gnu.org
Subject: 28.0.50; bytecompilation introduces bug in org-capture with certain
 template
Date: Tue, 27 Jul 2021 15:58:58 +0200
Dear emacs developers, I use org-capture a lot with
org-capture-templates. It stopped working a few days ago,
throwing a error message instead:

org-capture: Capture abort: Unknown template placeholder: "%^g"

This is due to a problem with byte compilation.  It does not
happen, if I remove all .elc files before starting emacs.


You may test it with this:

(custom-set-variables
 '(org-capture-templates '(("d" "diary" entry (file "~/notes.org") "*** %? %^g"))))


in   minconfig.el   and with this invocation of emacs:

~/src/emacs$ src/emacs -Q -l /tmp/minconfig.el --eval '(org-capture 0 "d")'

If this gives you an error, quit emacs, remove all .elc
-files:

~/src/emacs$ find -type f -print0| grep -zZ "\.elc$" |xargs -0r rm

start emacs again:

~/src/emacs$ src/emacs -Q -l /tmp/minconfig.el --eval '(org-capture 0 "d")'

and there is no error.



I narrowed it down to this commit:


51a86b6a0504d580d3e10efe41abf3ae42c90711 is the first bad commit
commit 51a86b6a0504d580d3e10efe41abf3ae42c90711
Author: Mattias Engdegård <mattiase <at> acm.org>
Date:   Tue Jul 20 17:23:11 2021 +0200

    Count (not X) as a switch condition

    * lisp/emacs-lisp/bytecomp.el (byte-compile--cond-switch-prefix):
    Treat (not VAR) and (null VAR) as (eq VAR nil) when computing the
    extent of switch ops.

diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el
index 6970c8a5055..2968f1af5df 100644
--- a/lisp/emacs-lisp/bytecomp.el
+++ b/lisp/emacs-lisp/bytecomp.el
@@ -4340,6 +4340,16 @@ byte-compile--cond-switch-prefix
                          (push value keys)
                          (push (cons (list value) (or body '(t))) cases))
                        t))))
+             ;; Treat (not X) as (eq X nil).
+             (`((,(or 'not 'null) ,(and var (pred symbolp))) . ,body)
+              (and (or (eq var switch-var) (not switch-var))
+                   (progn
+                     (setq switch-var var)
+                     (setq switch-test 'eq)
+                     (unless (memq nil keys)
+                       (push nil keys)
+                       (push (cons (list nil) (or body '(t))) cases))
+                     t)))
              (`((,(and fn (or 'memq 'memql 'member)) ,var ,expr) . ,body)
               (and (symbolp var)
                    (or (eq var switch-var) (not switch-var))

:040000 040000 ae3e2ceaa690965108fb8547ce6e90ecd2fcaaf3 28eec9e6920160dc5dff29e2567ee34b50924bec M      lisp


The problem came up recently on the org-mode mailing list:
https://www.mail-archive.com/emacs-orgmode <at> gnu.org/msg138065.html
Especially this message:
https://www.mail-archive.com/emacs-orgmode <at> gnu.org/msg138121.html
inspired me to do a git bisect and test builds if the throw
this error and if so, if it also happens after removing all
.elc files.

For every step in git bisect I did a

rm -rf * ; git checkout -f ; make 

in order to make sure that all .elc files are build afresh.


Ciao; Gregor
-- 
 -... --- .-. . -.. ..--.. ...-.-





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#49746; Package emacs. (Tue, 27 Jul 2021 15:26:02 GMT) Full text and rfc822 format available.

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

From: "Basil L. Contovounesios" <contovob <at> tcd.ie>
To: Gregor Zattler <telegraph <at> gmx.net>
Cc: 49746 <at> debbugs.gnu.org
Subject: Re: bug#49746: 28.0.50; bytecompilation introduces bug in
 org-capture with certain template
Date: Tue, 27 Jul 2021 16:25:21 +0100
Gregor Zattler <telegraph <at> gmx.net> writes:

> Dear emacs developers, I use org-capture a lot with
> org-capture-templates. It stopped working a few days ago,
> throwing a error message instead:
>
> org-capture: Capture abort: Unknown template placeholder: "%^g"
>
> This is due to a problem with byte compilation.  It does not
> happen, if I remove all .elc files before starting emacs.

This is the same issue as that described in https://bugs.gnu.org/49739,
right?

Thanks,

-- 
Basil




Reply sent to Mattias Engdegård <mattiase <at> acm.org>:
You have taken responsibility. (Tue, 27 Jul 2021 15:46:02 GMT) Full text and rfc822 format available.

Notification sent to Gregor Zattler <telegraph <at> gmx.net>:
bug acknowledged by developer. (Tue, 27 Jul 2021 15:46:02 GMT) Full text and rfc822 format available.

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

From: Mattias Engdegård <mattiase <at> acm.org>
To: Gregor Zattler <telegraph <at> gmx.net>
Cc: 49746-done <at> debbugs.gnu.org
Subject: bug#49746: 28.0.50; bytecompilation introduces bug in org-capture
 with certain template
Date: Tue, 27 Jul 2021 17:45:29 +0200
Thanks for reporting it. Your bisection saved a lot of time!

Fixed on master. Most embarrassing! Heaven knows what else was miscompiled.





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#49746; Package emacs. (Tue, 27 Jul 2021 16:37:02 GMT) Full text and rfc822 format available.

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

From: No Wayman <iarchivedmywholelife <at> gmail.com>
To: Mattias Engdegård <mattiase <at> acm.org>
Cc: "Basil L. Contovounesios" <contovob <at> tcd.ie>,
 Michael Heerdegen <michael_heerdegen <at> web.de>,
 Gregor Zattler <telegraph <at> gmx.net>, 49746 <at> debbugs.gnu.org
Subject: Re: bug#49746: 28.0.50; bytecompilation introduces bug in
 org-capture with certain template
Date: Tue, 27 Jul 2021 12:10:49 -0400
Mattias Engdegård <mattiase <at> acm.org> writes:

> forcemerge 49746 49739
> done
>
>>This is the same issue as that described in 
>>https://bugs.gnu.org/49739, right?
>
> Yes, thank you, let's close that one as well.

Gregor and I were on the same path!
I git bisected to the commit mentioned in #49746 this morning and 
was in the process of diffing the disassembled byte-code with a 
known good commit.
Looks like the issue was the strings were being compared via a 
jump-table-eq instead of a jump-table-equal bytecode instruction.
Built off of 949dd41c31dab69f7a5067bba324c28bb2cfbf8e and tested. 
Working fine now.

Thanks to all.





bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Wed, 25 Aug 2021 11:24:06 GMT) Full text and rfc822 format available.

This bug report was last modified 2 years and 245 days ago.

Previous Next


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