GNU bug report logs - #73270
31.0.50; comp.el comp--type-check-optim pass causes issues

Previous Next

Package: emacs;

Reported by: Iurie Marian <marian.iurie <at> gmail.com>

Date: Sun, 15 Sep 2024 08:29:01 UTC

Severity: normal

Found in version 31.0.50

Done: Andrea Corallo <acorallo <at> gnu.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 73270 in the body.
You can then email your comments to 73270 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#73270; Package emacs. (Sun, 15 Sep 2024 08:29:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Iurie Marian <marian.iurie <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sun, 15 Sep 2024 08:29:01 GMT) Full text and rfc822 format available.

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

From: Iurie Marian <marian.iurie <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org, acorallo <at> gnu.org
Subject: 31.0.50; comp.el comp--type-check-optim pass causes issues
Date: Sun, 15 Sep 2024 10:27:48 +0200
[Message part 1 (text/plain, inline)]
Dear Emacs maintainers,

I encountered an issue with latest Emacs' master branch. I am using a
package `pcre2el'
and I noticed a wrong behavior after updating Emacs. I tracked the change
which causes the
issue, and it seems it's the below commit:
#+begin_comment
a1775552cef5a8bc0ba13e802ecf343423a53364
Author:     Andrea Corallo <akrl <at> sdf.org>
AuthorDate: Tue May 23 11:18:07 2023 +0200
Commit:     Andrea Corallo <acorallo <at> gnu.org>
CommitDate: Thu Jul 11 16:26:49 2024 +0200
#+end_comment
probably the newly introduced `comp--type-check-optim' is causing the issue.

Issue description:
* `pcre2el''s rxt-adt->strings execution expectation
#+begin_comment
ELISP> (rxt-adt->strings (rxt-parse-pcre (rxt--add-flags "t([es]{2})" nil)))
("tss" "tse" "tes" "tee")
#+end_comment

* The error
#+begin_comment
ELISP> (rxt-adt->strings (rxt-parse-pcre (rxt--add-flags "t([es]{4})" nil)))
*** Eval error ***  Wrong type argument: listp, #s(rxt-repeat 4 4
#s(rxt-char-set-union (115 101) nil nil nil) t)
#+end_comment

That's how the above function [[
https://github.com/joddie/pcre2el/blob/b4d846d80dddb313042131cf2b8fbf647567e000/pcre2el.el#L2984C1-L3004C46][rxt-adt->strings]]
looks like:

#+begin_src emacs-lisp
(defun rxt-adt->strings (re)
  (cl-typecase re
    (rxt-primitive
     (list ""))
    (rxt-string
     (list (rxt-string-chars re)))
    (rxt-seq
     (rxt-seq-elts->strings (rxt-seq-elts re)))
    (rxt-choice
     (rxt-choice-elts->strings (rxt-choice-elts re)))
    (rxt-submatch
     (rxt-adt->strings (rxt-submatch-body re)))
    (rxt-submatch-numbered
     (rxt-adt->strings (rxt-submatch-numbered-body re)))
    (rxt-repeat
     (rxt-repeat->strings re))
    (rxt-char-set-union
     (rxt-char-set->strings re))
    (t
     (error "Can't generate productions of %s"
            (rxt-syntax-tree-readable re)))))
#+end_src

The issue comes from
#+begin_comment
  (cl-typecase re
#+end_comment

instead of matching below:
#+begin_comment
    (rxt-submatch
     (rxt-adt->strings (rxt-submatch-body re)))
#+end_comment

it wrongly matches:
#+begin_comment
    (rxt-seq
     (rxt-seq-elts->strings (rxt-seq-elts re)))
#+end_comment

and throws the error
#+begin_comment
ELISP> (rxt-adt->strings (rxt-parse-pcre (rxt--add-flags "t([es]{4})" nil)))
*** Eval error ***  Wrong type argument: listp, #s(rxt-repeat 4 4
#s(rxt-char-set-union (115 101) nil nil nil) t)
#+end_comment

To quickly check this I've added some traces:
#+begin_src emacs-lisp
(defun rxt-adt->strings (re)
  (message "type-of re: %S, re = %S" (type-of re) re)
  (cl-typecase re
    (rxt-primitive
     (progn (message "match: rxt-primitive")
            (list "")))
    (rxt-string
     (progn (message "match: rxt-string")
            (list (rxt-string-chars re))))
    (rxt-seq
     (progn (message "match: rxt-seq")
            (rxt-seq-elts->strings (rxt-seq-elts re))))
    (rxt-choice
     (progn (message "match: rxt-choice")
            (rxt-choice-elts->strings (rxt-choice-elts re))))
    (rxt-submatch
     (progn (message "match: rxt-submatch")
            (rxt-adt->strings (rxt-submatch-body re))))
    (rxt-submatch-numbered
     (progn (message "match: rxt-submatch-numbered")
            (rxt-adt->strings (rxt-submatch-numbered-body re))))
    (rxt-repeat
     (progn (message "match: rxt-repeat")
            (rxt-repeat->strings re)))
    (rxt-char-set-union
     (progn (message "match: rxt-char-set-union")
            (rxt-char-set->strings re)))
    (t
     (error "Can't generate productions of %s"
            (rxt-syntax-tree-readable re)))))
#+end_src

which produces below messages:

#+begin_comment
type-of re: rxt-seq, re = #s(rxt-seq (#s(rxt-string "t" nil)
#s(rxt-submatch #s(rxt-repeat 4 4 #s(rxt-char-set-union (115 101) nil nil
nil) t))))
match: rxt-seq

type-of re: rxt-string, re = #s(rxt-string "t" nil)
match: rxt-string

type-of re: rxt-submatch, re = #s(rxt-submatch #s(rxt-repeat 4 4
#s(rxt-char-set-union (115 101) nil nil nil) t))
match: rxt-seq
#+end_comment

By commenting line (`comp--type-check-optim') in `comp-passes' (see below),
it fixes locally the issue, which makes me think that this is the culprit.

#+begin_src emacs-lisp

(defconst comp-passes '(comp--spill-lap
                        comp--limplify
                        comp--fwprop
                        comp--call-optim
                        comp--ipa-pure
                        comp--add-cstrs
                        comp--fwprop
                        ;; comp--type-check-optim
                        comp--tco
                        comp--fwprop
                        comp--remove-type-hints
                        comp--sanitizer
                        comp--compute-function-types
                        comp--final)
  "Passes to be executed in order.")

#+end_src

Kind Regards,
Iurie



In GNU Emacs 31.0.50 (build 6, x86_64-pc-linux-gnu, GTK+ Version
 3.24.41, cairo version 1.18.0) of 2024-09-13 built on rrouwprlc0222
Repository revision: 7376623a244a91d1de5245645b4b3e8c9469d422
Repository branch: master
System Description: Ubuntu 24.04.1 LTS

Configured using:
 'configure 'CFLAGS= -O3 -fallow-store-data-races
 -fno-semantic-interposition -flto -fuse-ld=gold' LD=/usr/bin/ld.gold
 --prefix=/tools/emacs/build --sysconfdir=/etc
 --libexecdir=/tools/emacs/build/usr/lib
 --localstatedir=/tools/emacs/build/var --with-modules
 --without-gconf --without-gsettings --enable-link-time-optimization
 --with-x-toolkit=yes --without-xaw3d --without-m17n-flt --with-cairo
 --with-xwidgets --without-compress-install
 --with-native-compilation=aot --with-mailutils --with-xft --with-rsvg
 --with-pgtk'

Configured features:
CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS HARFBUZZ JPEG LIBOTF LIBSELINUX
LIBXML2 MODULES NATIVE_COMP NOTIFY INOTIFY PDUMPER PGTK PNG RSVG SECCOMP
SOUND SQLITE3 THREADS TIFF TOOLKIT_SCROLL_BARS TREE_SITTER WEBP XIM
XWIDGETS GTK3 ZLIB

Important settings:
  value of $LC_ALL: C
  value of $LANG: en_US.UTF-8
  value of $XMODIFIERS: @im=ibus
  locale-coding-system: utf-8
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#73270; Package emacs. (Mon, 16 Sep 2024 17:23:02 GMT) Full text and rfc822 format available.

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

From: Andrea Corallo <acorallo <at> gnu.org>
To: Iurie Marian <marian.iurie <at> gmail.com>
Cc: bug-gnu-emacs <at> gnu.org
Subject: Re: 31.0.50; comp.el comp--type-check-optim pass causes issues
Date: Mon, 16 Sep 2024 13:21:51 -0400
Thanks Iurie,

I'll try to look at this this week.

  Andrea




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#73270; Package emacs. (Tue, 15 Oct 2024 08:38:01 GMT) Full text and rfc822 format available.

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

From: Andrea Corallo <acorallo <at> gnu.org>
To: Iurie Marian <marian.iurie <at> gmail.com>
Cc: 73270 <at> debbugs.gnu.org
Subject: Re: bug#73270: 31.0.50; comp.el comp--type-check-optim pass causes
 issues
Date: Tue, 15 Oct 2024 04:35:09 -0400
Here is my minimal reproducer so far:

test.el===============
;; -*- lexical-binding: t; -*-
(require 'cl-lib)
(cl-defstruct base)
(cl-defstruct
    (child1 (:include base)))
(cl-defstruct
    (child2 (:include base)))
(cl-defstruct
    (child3 (:include base)))
(cl-defstruct
    (child4 (:include base)))

(defun foo (x)
  (message "type-of x: %S, x = %S" (type-of x) x)
  (cl-typecase x
    (child1
     (message "match: child1"))
    (child2
     (message "match: child2"))
    (child3
     (message "match: child3"))
    (child4
     (message "match: child4"))))

=============

(progn
  (load (native-compile "test.el"))
  (foo (make-child4)))

evaluates to : "match: child3"

I'm looking into it.

  Andrea




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#73270; Package emacs. (Tue, 15 Oct 2024 20:23:01 GMT) Full text and rfc822 format available.

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

From: Andrea Corallo <acorallo <at> gnu.org>
To: Iurie Marian <marian.iurie <at> gmail.com>
Cc: 73270 <at> debbugs.gnu.org
Subject: Re: bug#73270: 31.0.50; comp.el comp--type-check-optim pass causes
 issues
Date: Tue, 15 Oct 2024 16:22:09 -0400
Hi Iurie,

with cd739d3644b in master I believe this should be fixed.  Would you
verifying and reporting?

Thanks!

  Andrea




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#73270; Package emacs. (Tue, 15 Oct 2024 20:30:02 GMT) Full text and rfc822 format available.

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

From: Andrea Corallo <acorallo <at> gnu.org>
To: Iurie Marian <marian.iurie <at> gmail.com>
Cc: 73270 <at> debbugs.gnu.org
Subject: Re: bug#73270: 31.0.50; comp.el comp--type-check-optim pass causes
 issues
Date: Tue, 15 Oct 2024 16:29:01 -0400
Andrea Corallo <acorallo <at> gnu.org> writes:

> Hi Iurie,
>
> with cd739d3644b in master I believe this should be fixed.  Would you
>  verifying and reporting?
^^
like

  Andrea




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#73270; Package emacs. (Fri, 18 Oct 2024 17:54:02 GMT) Full text and rfc822 format available.

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

From: Iurie Marian <marian.iurie <at> gmail.com>
To: Andrea Corallo <acorallo <at> gnu.org>
Cc: 73270 <at> debbugs.gnu.org
Subject: Re: bug#73270: 31.0.50;
 comp.el comp--type-check-optim pass causes issues
Date: Fri, 18 Oct 2024 19:52:09 +0200
[Message part 1 (text/plain, inline)]
Hello Andrea,

Yes! I can confirm that it has been fixed. :)
Many thanks for your effort and great work!

Kind Regards,
Iurie

On Tue, 15 Oct 2024 at 22:29, Andrea Corallo <acorallo <at> gnu.org> wrote:

> Andrea Corallo <acorallo <at> gnu.org> writes:
>
> > Hi Iurie,
> >
> > with cd739d3644b in master I believe this should be fixed.  Would you
> >  verifying and reporting?
> ^^
> like
>
>   Andrea
>
[Message part 2 (text/html, inline)]

Reply sent to Andrea Corallo <acorallo <at> gnu.org>:
You have taken responsibility. (Mon, 21 Oct 2024 15:46:02 GMT) Full text and rfc822 format available.

Notification sent to Iurie Marian <marian.iurie <at> gmail.com>:
bug acknowledged by developer. (Mon, 21 Oct 2024 15:46:04 GMT) Full text and rfc822 format available.

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

From: Andrea Corallo <acorallo <at> gnu.org>
To: Iurie Marian <marian.iurie <at> gmail.com>
Cc: 73270-done <at> debbugs.gnu.org
Subject: Re: bug#73270: 31.0.50; comp.el comp--type-check-optim pass causes
 issues
Date: Mon, 21 Oct 2024 11:44:01 -0400
Iurie Marian <marian.iurie <at> gmail.com> writes:

> Hello Andrea,
>
> Yes! I can confirm that it has been fixed. :)
> Many thanks for your effort and great work!
>
> Kind Regards,
> Iurie

Thank you for the precise report 👍 closing

  Andrea




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Tue, 19 Nov 2024 12:24:17 GMT) Full text and rfc822 format available.

This bug report was last modified 209 days ago.

Previous Next


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