GNU logs - #74771, boring messages


Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#74771: Native compilation bug with struct predicates when lexical binding enabled (HEAD)
Resent-From: Eric Marsden <eric.marsden@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Tue, 10 Dec 2024 16:57:02 +0000
Resent-Message-ID: <handler.74771.B.173384976324392 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: report 74771
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: 74771 <at> debbugs.gnu.org
X-Debbugs-Original-To: bug-gnu-emacs@HIDDEN
Received: via spool by submit <at> debbugs.gnu.org id=B.173384976324392
          (code B ref -1); Tue, 10 Dec 2024 16:57:02 +0000
Received: (at submit) by debbugs.gnu.org; 10 Dec 2024 16:56:03 +0000
Received: from localhost ([127.0.0.1]:59395 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tL3Wk-0006LE-OE
	for submit <at> debbugs.gnu.org; Tue, 10 Dec 2024 11:56:03 -0500
Received: from lists.gnu.org ([209.51.188.17]:34370)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eric.marsden@HIDDEN>)
 id 1tL3Wj-0006Kh-DA
 for submit <at> debbugs.gnu.org; Tue, 10 Dec 2024 11:56:01 -0500
Received: from eggs.gnu.org ([2001:470:142:3::10])
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eric.marsden@HIDDEN>)
 id 1tL3We-0003d9-Oq
 for bug-gnu-emacs@HIDDEN; Tue, 10 Dec 2024 11:55:57 -0500
Received: from mail.risk-engineering.org ([2a01:4f8:c0c:a3f8::1])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.90_1) (envelope-from <eric.marsden@HIDDEN>)
 id 1tL3Wc-0005Ok-2f
 for bug-gnu-emacs@HIDDEN; Tue, 10 Dec 2024 11:55:56 -0500
DKIM-Signature: a=rsa-sha256; bh=L4bHhdgpmhsWX0oNDflsYvFo8zjYlXqiG7bvldHbLYU=; 
 c=relaxed/relaxed; d=risk-engineering.org;
 h=Subject:Subject:Sender:To:To:Cc:From:From:Date:Date:MIME-Version:MIME-Version:Content-Type:Content-Type:Content-Transfer-Encoding:Reply-To:In-Reply-To:Message-Id:Message-Id:References:Autocrypt:Openpgp;
 i=@risk-engineering.org; s=default; t=1733849784; v=1; x=1734281784;
 b=mUD0FXELGn6l8Kss8LCFb3aT4Rl+iplDDDXk0QToriYB+vQ+tJGHfv3cUUmLGV7nf+ebNsMo
 9T6l8Cxo/eZ9m+CH2XuHd9I9Sq2NLjWDSUnjEAoQLsPvk/0OaGF+H1Yk+pMHhV/sz+5wJ/AXawf
 VatBlS1vXFOd1TwpDfcsNJw4tlBau/lnWCrWtujK+xQJ8fwmb4i9+sC+JlDwQ8y/an/hLPp1KXA
 UoLUmy5SZcE+T8fwRrYpActX1j23zDnsHHBgoL088o925IykOox5+TB5i+Bw2lmlgz1Spos0df7
 mAFTr0LgBomI3oF+K1JmNy2iWDY/YIZMPv+XtAZeyGzmQ==
Received: by mail.risk-engineering.org (envelope-sender
 <eric.marsden@HIDDEN>) with ESMTPS id f3158dc9; Tue, 10 Dec
 2024 17:56:24 +0100
Content-Type: multipart/mixed; boundary="------------HU0BgGQcJTHB0VwisiJ7Orqy"
Message-ID: <0446a656-1fa2-4160-a8ba-69c060a52589@HIDDEN>
Date: Tue, 10 Dec 2024 17:55:46 +0100
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
Content-Language: en-US
From: Eric Marsden <eric.marsden@HIDDEN>
Received-SPF: pass client-ip=2a01:4f8:c0c:a3f8::1;
 envelope-from=eric.marsden@HIDDEN;
 helo=mail.risk-engineering.org
X-Spam_score_int: -16
X-Spam_score: -1.7
X-Spam_bar: -
X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, DKIM_INVALID=0.1,
 DKIM_SIGNED=0.1, SPF_HELO_NONE=0.001,
 SPF_PASS=-0.001 autolearn=no autolearn_force=no
X-Spam_action: no action
X-Spam-Score: -1.4 (-)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.4 (--)

This is a multi-part message in MIME format.
--------------HU0BgGQcJTHB0VwisiJ7Orqy
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit

Hi,

With the attached source file, Emacs miscompiles the struct predicate such
that a repeated call to the predicate on a non-struct object returns t.
This occurs with current HEAD on Linux/AMD64, but not on the Emacs 30.0.92
pretest. It does not occur when the lexical binding cookie is not present.

% /opt/emacs/bin/emacs -Q --batch --eval "(load (native-compile \"/tmp/bug.el\"))" -f run
Loading /home/emarsden/.emacs.d/eln-cache/31.0.50-c021c983/bug-59c4b27c-c70072f9.eln (native compiled elisp)...
Running in GNU Emacs 31.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.43, cairo version 1.18.2)
  of 2024-12-09
is? nil
is? t   ;; expecting nil
bar: 111


--------------HU0BgGQcJTHB0VwisiJ7Orqy
Content-Type: text/x-emacs-lisp; charset=UTF-8; name="bug.el"
Content-Disposition: attachment; filename="bug.el"
Content-Transfer-Encoding: base64

Ozs7ICAgLSotIGxleGljYWwtYmluZGluZzogdCAtKi0KOzsKOzsgL29wdC9lbWFjcy9iaW4v
ZW1hY3MgLVEgLS1iYXRjaCAtTCAuIC0tZXZhbCAiKGxvYWQgKG5hdGl2ZS1jb21waWxlIFwi
L3RtcC9idWcuZWxcIikpIiAtZiBydW4KCihyZXF1aXJlICdjbC1saWIpCgooY2wtZGVmc3Ry
dWN0IGZvb2JsZXMgYmFyIGJheikKCihkZWZ1biBidWcgKGZvbykKICAobWVzc2FnZSAiaXM/
ICVzIiAoZm9vYmxlcy1wIGZvbykpCiAgKG1lc3NhZ2UgImlzPyAlcyIgKGZvb2JsZXMtcCBm
b28pKQogIChtZXNzYWdlICJiYXI6ICVzIiAoZm9vYmxlcy1iYXIgZm9vKSkpCgooZGVmdW4g
cnVuICgpCiAgKG1lc3NhZ2UgIlJ1bm5pbmcgaW4gJXMiICh2ZXJzaW9uKSkKICAobGV0ICgo
Zm9vICJmb28iKSkKICAgIChidWcgZm9vKSkpCgoKCg==

--------------HU0BgGQcJTHB0VwisiJ7Orqy--




Message sent:


Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0
X-Mailer: MIME-tools 5.505 (Entity 5.505)
Content-Type: text/plain; charset=utf-8
X-Loop: help-debbugs@HIDDEN
From: help-debbugs@HIDDEN (GNU bug Tracking System)
To: Eric Marsden <eric.marsden@HIDDEN>
Subject: bug#74771: Acknowledgement (Native compilation bug with struct
 predicates when lexical binding enabled (HEAD))
Message-ID: <handler.74771.B.173384976324392.ack <at> debbugs.gnu.org>
References: <0446a656-1fa2-4160-a8ba-69c060a52589@HIDDEN>
X-Gnu-PR-Message: ack 74771
X-Gnu-PR-Package: emacs
Reply-To: 74771 <at> debbugs.gnu.org
Date: Tue, 10 Dec 2024 16:57:02 +0000

Thank you for filing a new bug report with debbugs.gnu.org.

This is an automatically generated reply to let you know your message
has been received.

Your message is being forwarded to the package maintainers and other
interested parties for their attention; they will reply in due course.

Your message has been sent to the package maintainer(s):
 bug-gnu-emacs@HIDDEN

If you wish to submit further information on this problem, please
send it to 74771 <at> debbugs.gnu.org.

Please do not send mail to help-debbugs@HIDDEN unless you wish
to report a problem with the Bug-tracking system.

--=20
74771: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D74771
GNU Bug Tracking System
Contact help-debbugs@HIDDEN with problems


Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#74771: Native compilation bug with struct predicates when lexical binding enabled (HEAD)
Resent-From: Pip Cet <pipcet@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Tue, 10 Dec 2024 21:22:02 +0000
Resent-Message-ID: <handler.74771.B74771.17338656779879 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 74771
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: Eric Marsden <eric.marsden@HIDDEN>
Cc: 74771 <at> debbugs.gnu.org
Received: via spool by 74771-submit <at> debbugs.gnu.org id=B74771.17338656779879
          (code B ref 74771); Tue, 10 Dec 2024 21:22:02 +0000
Received: (at 74771) by debbugs.gnu.org; 10 Dec 2024 21:21:17 +0000
Received: from localhost ([127.0.0.1]:59812 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tL7fR-0002ZG-AZ
	for submit <at> debbugs.gnu.org; Tue, 10 Dec 2024 16:21:17 -0500
Received: from mail-4316.protonmail.ch ([185.70.43.16]:42827)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <pipcet@HIDDEN>) id 1tL7fO-0002YM-G2
 for 74771 <at> debbugs.gnu.org; Tue, 10 Dec 2024 16:21:15 -0500
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com;
 s=protonmail3; t=1733865668; x=1734124868;
 bh=AGpgk17BWxs/uHembsjpoEOXRloBeStBQCxfnwm2d00=;
 h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References:
 Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID:
 Message-ID:BIMI-Selector:List-Unsubscribe:List-Unsubscribe-Post;
 b=pZbrWF3P33Dxib/iDGBDCaG8Pemx5ZrImGj4gydSpd0IsYCHfEC0lfKefdoruUb+Y
 +zgcLPR7r/4+FfDrLKcdeRGOYujtVGgxzUEoPWTxJcAU6JgRo427ObnTXqjDpwZ4DT
 IEUnM90evJrDCeAHPHLHqZABDrlRhcqd6bvF7DEmzbzrfkBmXWTQ5nSOYigAS/qs/x
 gWbK9nWbq8FzRfsTeNhXox98B+56wmQAsBcV9fcGrKVVhueyXN/dk9fAzWm8Latf+u
 PD9GT64JVZf1tcsUw/WUG6eYomUtZqBEwQ75LDeZED0uOxmURDpgeUBsIxI3kU1t3/
 BcjSFzAYS4cmQ==
Date: Tue, 10 Dec 2024 21:21:04 +0000
From: Pip Cet <pipcet@HIDDEN>
Message-ID: <87jzc7me0b.fsf@HIDDEN>
In-Reply-To: <0446a656-1fa2-4160-a8ba-69c060a52589@HIDDEN>
References: <0446a656-1fa2-4160-a8ba-69c060a52589@HIDDEN>
Feedback-ID: 112775352:user:proton
X-Pm-Message-ID: 7aab1edf49afcfdf44708eb1f8ef9b0dace55ef4
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: 0.0 (/)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

"Eric Marsden" <eric.marsden@HIDDEN> writes:

> Hi,
>
> With the attached source file, Emacs miscompiles the struct predicate suc=
h
> that a repeated call to the predicate on a non-struct object returns t.
> This occurs with current HEAD on Linux/AMD64, but not on the Emacs 30.0.9=
2
> pretest. It does not occur when the lexical binding cookie is not present=
.
>
> % /opt/emacs/bin/emacs -Q --batch --eval "(load (native-compile \"/tmp/bu=
g.el\"))" -f run
> Loading /home/emarsden/.emacs.d/eln-cache/31.0.50-c021c983/bug-59c4b27c-c=
70072f9.eln (native compiled elisp)...
> Running in GNU Emacs 31.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version =
3.24.43, cairo version 1.18.2)
>  =C2=A0of 2024-12-09
> is? nil
> is? t=C2=A0=C2=A0 ;; expecting nil
> bar: 111
>
> [2. text/x-emacs-lisp; bug.el]...

Can you try this patch?

diff --git a/lisp/emacs-lisp/comp.el b/lisp/emacs-lisp/comp.el
index 0d40f05bef1..c3e9a8be66d 100644
--- a/lisp/emacs-lisp/comp.el
+++ b/lisp/emacs-lisp/comp.el
@@ -2029,15 +2029,18 @@ comp--add-cond-cstrs
               (call symbol-value ,(and (pred comp-cstr-cl-tag-p) mvar-tag)=
))
          (set ,(and (pred comp-mvar-p) mvar-3)
               (call memq ,(and (pred comp-mvar-p) mvar-1) ,(and (pred comp=
-mvar-p) mvar-2)))
-         (cond-jump ,(and (pred comp-mvar-p) mvar-3) ,(pred comp-mvar-p) ,=
bb1 ,bb2))
-       (comp--emit-assume 'and mvar-tested
-                         (make--comp-mvar :type (comp-cstr-cl-tag mvar-tag=
))
-                         (comp--add-cond-cstrs-target-block b bb2)
-                         nil)
-       (comp--emit-assume 'and mvar-tested
-                         (make--comp-mvar :type (comp-cstr-cl-tag mvar-tag=
))
-                         (comp--add-cond-cstrs-target-block b bb1)
-                         t))
+         (cond-jump ,(and (pred comp-mvar-p) mvar-3) ,(and (pred comp-mvar=
-p) mvar-4) ,bb1 ,bb2))
+       (cond
+        ((and (comp-cstr-imm-vld-p mvar-4)
+              (eq (comp-cstr-imm mvar-4) t))
+         (comp--emit-assume 'and mvar-tested
+                            (make--comp-mvar :type (comp-cstr-cl-tag mvar-=
tag))
+                            (comp--add-cond-cstrs-target-block b bb2)
+                            nil)
+         (comp--emit-assume 'and mvar-tested
+                            (make--comp-mvar :type (comp-cstr-cl-tag mvar-=
tag))
+                            (comp--add-cond-cstrs-target-block b bb1)
+                            t))))
       (`((set ,(and (pred comp-mvar-p) cmp-res)
               (,(pred comp--call-op-p)
                ,(and (or (pred comp--equality-fun-p)

IIUC, the code blindly assumes that cond-jump would use t as its second
argument.  In your code, the second argument was nil, so the assumptions
were put into the wrong basic blocks.

It looks like there are quite a few such assumptions in comp.el. I think
we should fix them all to ensure that they test for truth, not
falsehood.  After that, we'll have to decide whether it's worth it
to optimize the negated cases.

Pip





Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#74771: Native compilation bug with struct predicates when lexical binding enabled (HEAD)
Resent-From: Pip Cet <pipcet@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Tue, 10 Dec 2024 22:13:02 +0000
Resent-Message-ID: <handler.74771.B74771.173386873826931 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 74771
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: Eric Marsden <eric.marsden@HIDDEN>
Cc: 74771 <at> debbugs.gnu.org
Received: via spool by 74771-submit <at> debbugs.gnu.org id=B74771.173386873826931
          (code B ref 74771); Tue, 10 Dec 2024 22:13:02 +0000
Received: (at 74771) by debbugs.gnu.org; 10 Dec 2024 22:12:18 +0000
Received: from localhost ([127.0.0.1]:59899 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tL8So-00070H-Fd
	for submit <at> debbugs.gnu.org; Tue, 10 Dec 2024 17:12:18 -0500
Received: from mail-40134.protonmail.ch ([185.70.40.134]:17291)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <pipcet@HIDDEN>) id 1tL8Sl-0006zW-SA
 for 74771 <at> debbugs.gnu.org; Tue, 10 Dec 2024 17:12:16 -0500
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com;
 s=protonmail3; t=1733868729; x=1734127929;
 bh=ECz+GABjbmQg6rV1h1I3os4NfX5GAshKYYs9fTTP/oE=;
 h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References:
 Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID:
 Message-ID:BIMI-Selector:List-Unsubscribe:List-Unsubscribe-Post;
 b=OyEnIsy9T12lkRAhMml0Nbuxqw4n5gdLNG5e4cJxGlKKtPl7oj0DbZZdXP6BIcHeA
 cPHuhpDoJDLVE4nste0G4B3+qyptWtJIyl2UlMd0UhmyFbbC9udW0gZltkGX7sAPaw
 0ZFUGcXKY+quPJ9Nc60diQYM6HXBDtB1QcRqKkAyYQV7Y4ZCklaA0t3mqt01iq8eRo
 a0UkRBEDAXWn9LUh+ALV2tBLDz+J9b5MoxCFlXQR0oNBsEys9zrJFxZWwuVr2+EhOu
 Q6KkLbkcT8d2XlkBUbkCl7Ffa6mmccr5LPnPooL+ESdfYHsTXkdGUFEdtl7yOnQEMq
 BsihNXtUD50ag==
Date: Tue, 10 Dec 2024 22:12:03 +0000
From: Pip Cet <pipcet@HIDDEN>
Message-ID: <87frmvmbnb.fsf@HIDDEN>
In-Reply-To: <0446a656-1fa2-4160-a8ba-69c060a52589@HIDDEN>
References: <0446a656-1fa2-4160-a8ba-69c060a52589@HIDDEN>
Feedback-ID: 112775352:user:proton
X-Pm-Message-ID: 6d9ec4763e42cee9b40475194568e73d7de7dab4
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: 0.0 (/)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Pip Cet <pipcet@HIDDEN> writes:

> IIUC, the code blindly assumes that cond-jump would use t as its second
> argument.  In your code, the second argument was nil, so the assumptions
> were put into the wrong basic blocks.

I did not understand correctly.  It seems cond-jump is still limited to
a nil second argument, which is an undocumented assumption that comp.el
continues to rely on.

I still think comp--emit-assume does the wrong thing when negating an
assumption, but we've been there before...

Pip





Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#74771: Native compilation bug with struct predicates when lexical binding enabled (HEAD)
Resent-From: Eli Zaretskii <eliz@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Wed, 11 Dec 2024 12:33:02 +0000
Resent-Message-ID: <handler.74771.B74771.173392035116983 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 74771
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: Pip Cet <pipcet@HIDDEN>, Andrea Corallo <acorallo@HIDDEN>
Cc: 74771 <at> debbugs.gnu.org, eric.marsden@HIDDEN
Received: via spool by 74771-submit <at> debbugs.gnu.org id=B74771.173392035116983
          (code B ref 74771); Wed, 11 Dec 2024 12:33:02 +0000
Received: (at 74771) by debbugs.gnu.org; 11 Dec 2024 12:32:31 +0000
Received: from localhost ([127.0.0.1]:33347 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tLLtH-0004Pq-3Z
	for submit <at> debbugs.gnu.org; Wed, 11 Dec 2024 07:32:31 -0500
Received: from eggs.gnu.org ([209.51.188.92]:60914)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1tLLtF-0004PX-AM
 for 74771 <at> debbugs.gnu.org; Wed, 11 Dec 2024 07:32:30 -0500
Received: from fencepost.gnu.org ([2001:470:142:3::e])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1tLLt8-000832-N7; Wed, 11 Dec 2024 07:32:22 -0500
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date:
 mime-version; bh=9ZzBinerJzUgxjjvjYHlP+RfNUvA0YNgXHOTyeSegAc=; b=ez0QWNcz+0sG
 MS7ohonddI7179sRD/pn9h/wJhvIc7nYLk+NBgAHA4Td3AqGzQvtos41FgNEz2QY7tkeFrZ+jea5N
 e5lGBPJW/EWWgUI1sEwhiHYPpFzu5MCH7NydiDYIOtSc+RBu3J/bL9D39SHrk3UvYos+DqTcrKuhh
 hcZkCPH5Q5ReuH5GxJ2/47PxPgh69Z/KBa7V9V2hKZrzLCsX1uM8DVvFBN/UXgLhaD512GjokF03c
 xVvsAoOKMsSIcMQ4fAJAFmfJOQ7CoqokqiRGZxc7THEfVwYLAf3ModlMapeIyCpfRJ/rFDj3busZG
 UAfTG03/FxIbPxUsjN+7hQ==;
Date: Wed, 11 Dec 2024 14:32:15 +0200
Message-Id: <86ldwm4cz4.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
In-Reply-To: <87frmvmbnb.fsf@HIDDEN> (bug-gnu-emacs@HIDDEN)
References: <0446a656-1fa2-4160-a8ba-69c060a52589@HIDDEN>
 <87frmvmbnb.fsf@HIDDEN>
X-Spam-Score: -2.3 (--)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> Cc: 74771 <at> debbugs.gnu.org
> Date: Tue, 10 Dec 2024 22:12:03 +0000
> From:  Pip Cet via "Bug reports for GNU Emacs,
>  the Swiss army knife of text editors" <bug-gnu-emacs@HIDDEN>
> 
> Pip Cet <pipcet@HIDDEN> writes:
> 
> > IIUC, the code blindly assumes that cond-jump would use t as its second
> > argument.  In your code, the second argument was nil, so the assumptions
> > were put into the wrong basic blocks.
> 
> I did not understand correctly.  It seems cond-jump is still limited to
> a nil second argument, which is an undocumented assumption that comp.el
> continues to rely on.
> 
> I still think comp--emit-assume does the wrong thing when negating an
> assumption, but we've been there before...

Let's hear from Andrea (CC'ed) about this.




Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#74771: Native compilation bug with struct predicates when lexical binding enabled (HEAD)
Resent-From: Pip Cet <pipcet@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Wed, 11 Dec 2024 14:02:01 +0000
Resent-Message-ID: <handler.74771.B74771.17339256885754 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 74771
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: Eli Zaretskii <eliz@HIDDEN>
Cc: Andrea Corallo <acorallo@HIDDEN>, 74771 <at> debbugs.gnu.org, eric.marsden@HIDDEN
Received: via spool by 74771-submit <at> debbugs.gnu.org id=B74771.17339256885754
          (code B ref 74771); Wed, 11 Dec 2024 14:02:01 +0000
Received: (at 74771) by debbugs.gnu.org; 11 Dec 2024 14:01:28 +0000
Received: from localhost ([127.0.0.1]:33554 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tLNHL-0001Uj-LU
	for submit <at> debbugs.gnu.org; Wed, 11 Dec 2024 09:01:27 -0500
Received: from mail-40131.protonmail.ch ([185.70.40.131]:11079)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <pipcet@HIDDEN>) id 1tLNHH-0001UE-VH
 for 74771 <at> debbugs.gnu.org; Wed, 11 Dec 2024 09:01:26 -0500
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com;
 s=protonmail3; t=1733925678; x=1734184878;
 bh=0jA6/DWuJXJc65oXVTsvEDTGtfM36piCvOvEFickgSo=;
 h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References:
 Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID:
 Message-ID:BIMI-Selector:List-Unsubscribe:List-Unsubscribe-Post;
 b=VaWSRt7VtVANI1oBbb22ed0RGWvnXSsU3+n5ULbBCaHmIUt7EDjOBtG7jAssMXWjb
 uttvwTrqBahTVPO71OJ4U5LddBRLujFLn4MXTPiDTZTXLuJ/qZQwVHUAIMG46YX2gr
 wcZXvE/4SPeXzIAu+F30PLIynWdOZRsfjbOymvvTo8+b+fYZt3PI3KQiDoDHl1N8Fa
 H9cYlJ+dlMQv+Kqdp1TgbSSo3Jra5TgkOOXU9/2N/RCWQy1eEPyzI3TuAG0l3JyMdN
 kudh/iVECIJnd9O1WQVR8xpRl32YcXpA2NYF+glPf32zz2fxdkcD385b1NmlRLbdZu
 L5A9tJz094yuA==
Date: Wed, 11 Dec 2024 14:01:13 +0000
From: Pip Cet <pipcet@HIDDEN>
Message-ID: <87frmul3pd.fsf@HIDDEN>
In-Reply-To: <86ldwm4cz4.fsf@HIDDEN>
References: <0446a656-1fa2-4160-a8ba-69c060a52589@HIDDEN>
 <87frmvmbnb.fsf@HIDDEN> <86ldwm4cz4.fsf@HIDDEN>
Feedback-ID: 112775352:user:proton
X-Pm-Message-ID: 5f4e4a191696d808ce7b99e41bb0bcf6575b3ae6
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: 0.0 (/)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

"Eli Zaretskii" <eliz@HIDDEN> writes:

>> Cc: 74771 <at> debbugs.gnu.org
>> Date: Tue, 10 Dec 2024 22:12:03 +0000
>> From:  Pip Cet via "Bug reports for GNU Emacs,
>>  the Swiss army knife of text editors" <bug-gnu-emacs@HIDDEN>
>>
>> Pip Cet <pipcet@HIDDEN> writes:
>>
>> > IIUC, the code blindly assumes that cond-jump would use t as its secon=
d
>> > argument.  In your code, the second argument was nil, so the assumptio=
ns
>> > were put into the wrong basic blocks.
>>
>> I did not understand correctly.  It seems cond-jump is still limited to
>> a nil second argument, which is an undocumented assumption that comp.el
>> continues to rely on.
>>
>> I still think comp--emit-assume does the wrong thing when negating an
>> assumption, but we've been there before...
>
> Let's hear from Andrea (CC'ed) about this.

You're right. I have a new theory, but as it boils down to something
that has been discussed before (whether "assume" pseudo-insns apply to
individual mvars or to all mvars sharing a slot - my understanding is it
has to be the latter, so we end up making invalid assumptions about the
new mvar in the slot based on things we know about the old, clobbered
mvar), it's best to let Andrea handle this one.  I'll just disable
nativecomp assume pseudo-insns for my builds as I don't want to run into
this bug.

Pip





Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#74771: Native compilation bug with struct predicates when lexical binding enabled (HEAD)
Resent-From: Andrea Corallo <acorallo@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Wed, 11 Dec 2024 22:30:02 +0000
Resent-Message-ID: <handler.74771.B74771.173395618822556 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 74771
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: Eric Marsden <eric.marsden@HIDDEN>
Cc: 74771 <at> debbugs.gnu.org
Received: via spool by 74771-submit <at> debbugs.gnu.org id=B74771.173395618822556
          (code B ref 74771); Wed, 11 Dec 2024 22:30:02 +0000
Received: (at 74771) by debbugs.gnu.org; 11 Dec 2024 22:29:48 +0000
Received: from localhost ([127.0.0.1]:36629 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tLVDH-0005rh-EL
	for submit <at> debbugs.gnu.org; Wed, 11 Dec 2024 17:29:47 -0500
Received: from eggs.gnu.org ([209.51.188.92]:39094)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <acorallo@HIDDEN>) id 1tLVDF-0005rG-B1
 for 74771 <at> debbugs.gnu.org; Wed, 11 Dec 2024 17:29:46 -0500
Received: from fencepost.gnu.org ([2001:470:142:3::e])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <acorallo@HIDDEN>)
 id 1tLVD6-0005ET-MX; Wed, 11 Dec 2024 17:29:39 -0500
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=MIME-Version:Date:References:In-Reply-To:Subject:To:
 From; bh=NEzbnZxLbMR4yYGBYu/C9Vhy6UF6fYjDe4vYnTCpEm8=; b=n0pn2+FUxlitjaP7neSj
 zvBkrvdKMKT6d/ki3As1mZPunCH/L8+/akYsg2uQV16q17HvJitTcCgOcv4qS/3L+8cfLaS6+lzer
 Ma8nDyVkaS/lSpcQNNdMWoY4DwY3F7VgBf1oJDBZA/JnNVoCvUky4syAMEkCtb8kaaW628aXprKG0
 WD8DzcV4aJk6pm3FfLujWAClbZ9Qb21CD88b5ANA4sjlgTYYh3uaDlrF5XeRLlfAwMZEZ7pFefNOd
 dkk3WvJJYse8/XLxfnaXYgc6zdvXga2R1A2MqA0I5gvvs2VsCvnCb4rYZoIZUQhgcOw9VIisFb1Vm
 eyd78isakM6iNw==;
Received: from acorallo by fencepost.gnu.org with local (Exim 4.90_1)
 (envelope-from <acorallo@HIDDEN>)
 id 1tLVD5-0001b2-I0; Wed, 11 Dec 2024 17:29:35 -0500
From: Andrea Corallo <acorallo@HIDDEN>
In-Reply-To: <0446a656-1fa2-4160-a8ba-69c060a52589@HIDDEN> (Eric
 Marsden's message of "Tue, 10 Dec 2024 17:55:46 +0100")
References: <0446a656-1fa2-4160-a8ba-69c060a52589@HIDDEN>
Date: Wed, 11 Dec 2024 17:29:34 -0500
Message-ID: <yp15xnpg8fl.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: -2.3 (--)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

Eric Marsden <eric.marsden@HIDDEN> writes:

> Hi,
>
> With the attached source file, Emacs miscompiles the struct predicate such
> that a repeated call to the predicate on a non-struct object returns t.
> This occurs with current HEAD on Linux/AMD64, but not on the Emacs 30.0.92
> pretest. It does not occur when the lexical binding cookie is not present.
>
> % /opt/emacs/bin/emacs -Q --batch --eval "(load (native-compile \"/tmp/bu=
g.el\"))" -f run
> Loading /home/emarsden/.emacs.d/eln-cache/31.0.50-c021c983/bug-59c4b27c-c=
70072f9.eln (native compiled elisp)...
> Running in GNU Emacs 31.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version =
3.24.43, cairo version 1.18.2)
> =C2=A0of 2024-12-09
> is? nil
> is? t=C2=A0=C2=A0 ;; expecting nil
> bar: 111
>
> ;;;   -*- lexical-binding: t -*-
> ;;
> ;; /opt/emacs/bin/emacs -Q --batch -L . --eval "(load (native-compile \"/=
tmp/bug.el\"))" -f run
>
> (require 'cl-lib)
>
> (cl-defstruct foobles bar baz)
>
> (defun bug (foo)
>   (message "is? %s" (foobles-p foo))
>   (message "is? %s" (foobles-p foo))
>   (message "bar: %s" (foobles-bar foo)))
>
> (defun run ()
>   (message "Running in %s" (version))
>   (let ((foo "foo"))
>     (bug foo)))

Hi Eric,

thanks for the report, I'll look at this in the coming days.

  Andrea




Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#74771: Native compilation bug with struct predicates when lexical binding enabled (HEAD)
Resent-From: Eli Zaretskii <eliz@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Sat, 28 Dec 2024 10:59:02 +0000
Resent-Message-ID: <handler.74771.B74771.173538351622702 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 74771
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: Andrea Corallo <acorallo@HIDDEN>
Cc: 74771 <at> debbugs.gnu.org, eric.marsden@HIDDEN
Received: via spool by 74771-submit <at> debbugs.gnu.org id=B74771.173538351622702
          (code B ref 74771); Sat, 28 Dec 2024 10:59:02 +0000
Received: (at 74771) by debbugs.gnu.org; 28 Dec 2024 10:58:36 +0000
Received: from localhost ([127.0.0.1]:48904 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tRUWh-0005u5-Rx
	for submit <at> debbugs.gnu.org; Sat, 28 Dec 2024 05:58:36 -0500
Received: from eggs.gnu.org ([209.51.188.92]:35224)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1tRUWf-0005ts-Hn
 for 74771 <at> debbugs.gnu.org; Sat, 28 Dec 2024 05:58:33 -0500
Received: from fencepost.gnu.org ([2001:470:142:3::e])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1tRUWZ-0003MR-TW; Sat, 28 Dec 2024 05:58:27 -0500
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From:
 Date; bh=UqS6CdiQulxSny/S0dwfpCaehgy40IPpALMSWunZ5AI=; b=frJnoEkrEb0Scw0+AmAv
 BEzxWsXNtQeDC1tcp1K8RS004DCuMhe3Q1rQYod8V4OUnstvJfA2s1FIVM/nXF/mJaLo8t7Wuee4W
 FXd8f6K3bAz7/58QF6dfD/F+ubvjyyg2T5AGtK6xW1oBuPrAOU/n/4FwpHvSU85s0B0jaIoiA/X6W
 jkDU3k7JitBkHjdQqkBLHYrATYmm7bh2QxekdmyJsE4LyapahTC9Eb897RyAB3OztEht62HR0LDDX
 v+pG5bCqtqvZw1EetjGgYVGBuqirDr1VYQFhCxwm5i6dhEmJhGs5cGPTM38wvqGKJAt0CtqgVJgeQ
 U/kZaMenKFk7Nw==;
Date: Sat, 28 Dec 2024 12:58:22 +0200
Message-Id: <865xn4ul9t.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
In-Reply-To: <yp15xnpg8fl.fsf@HIDDEN> (message from Andrea Corallo
 on Wed, 11 Dec 2024 17:29:34 -0500)
References: <0446a656-1fa2-4160-a8ba-69c060a52589@HIDDEN>
 <yp15xnpg8fl.fsf@HIDDEN>
MIME-version: 1.0
Content-type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
X-Spam-Score: -2.3 (--)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> Cc: 74771 <at> debbugs.gnu.org
> From: Andrea Corallo <acorallo@HIDDEN>
> Date: Wed, 11 Dec 2024 17:29:34 -0500
> 
> Eric Marsden <eric.marsden@HIDDEN> writes:
> 
> > Hi,
> >
> > With the attached source file, Emacs miscompiles the struct predicate such
> > that a repeated call to the predicate on a non-struct object returns t.
> > This occurs with current HEAD on Linux/AMD64, but not on the Emacs 30.0.92
> > pretest. It does not occur when the lexical binding cookie is not present.
> >
> > % /opt/emacs/bin/emacs -Q --batch --eval "(load (native-compile \"/tmp/bug.el\"))" -f run
> > Loading /home/emarsden/.emacs.d/eln-cache/31.0.50-c021c983/bug-59c4b27c-c70072f9.eln (native compiled elisp)...
> > Running in GNU Emacs 31.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.43, cairo version 1.18.2)
> >  of 2024-12-09
> > is? nil
> > is? t   ;; expecting nil
> > bar: 111
> >
> > ;;;   -*- lexical-binding: t -*-
> > ;;
> > ;; /opt/emacs/bin/emacs -Q --batch -L . --eval "(load (native-compile \"/tmp/bug.el\"))" -f run
> >
> > (require 'cl-lib)
> >
> > (cl-defstruct foobles bar baz)
> >
> > (defun bug (foo)
> >   (message "is? %s" (foobles-p foo))
> >   (message "is? %s" (foobles-p foo))
> >   (message "bar: %s" (foobles-bar foo)))
> >
> > (defun run ()
> >   (message "Running in %s" (version))
> >   (let ((foo "foo"))
> >     (bug foo)))
> 
> Hi Eric,
> 
> thanks for the report, I'll look at this in the coming days.

Any progress here?




Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#74771: Native compilation bug with struct predicates when lexical binding enabled (HEAD)
Resent-From: Andrea Corallo <acorallo@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Sun, 29 Dec 2024 09:46:02 +0000
Resent-Message-ID: <handler.74771.B74771.173546550322462 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 74771
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: Eli Zaretskii <eliz@HIDDEN>
Cc: 74771 <at> debbugs.gnu.org, eric.marsden@HIDDEN
Received: via spool by 74771-submit <at> debbugs.gnu.org id=B74771.173546550322462
          (code B ref 74771); Sun, 29 Dec 2024 09:46:02 +0000
Received: (at 74771) by debbugs.gnu.org; 29 Dec 2024 09:45:03 +0000
Received: from localhost ([127.0.0.1]:53771 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tRpr5-0005qC-57
	for submit <at> debbugs.gnu.org; Sun, 29 Dec 2024 04:45:03 -0500
Received: from eggs.gnu.org ([209.51.188.92]:40378)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <acorallo@HIDDEN>) id 1tRpr3-0005pO-87
 for 74771 <at> debbugs.gnu.org; Sun, 29 Dec 2024 04:45:01 -0500
Received: from fencepost.gnu.org ([2001:470:142:3::e])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <acorallo@HIDDEN>)
 id 1tRpqx-00043f-TA; Sun, 29 Dec 2024 04:44:55 -0500
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=MIME-Version:Date:References:In-Reply-To:Subject:To:
 From; bh=MmKr2wWBrBrLSpB9qrgyLRVj1LS4qraFC0sSqBgcOeo=; b=aYF8eNnE8Cv7e9lAL9cP
 bzNP4frkj19S+N05leUl/OAYabeMWV5ShdW2I2hiKI3d/qkdR6Sv2lgYq/wQkmcxNh4itpkJWIoc8
 i7EsB/0HVTS30AxdCFz82L4+oZC2ncoei9gahPt6rRlp33bZj+JkzHyUvpOFgpCAXp7Ewu8AlSRQ3
 9Uya032ZK4fB2hjlJymah7XP8KasILafLJfJ0jJ57adQR6ljvdIx0MKC8RT1FZL5o06JBgx1wJKl3
 NhX4AeMSoGyFNVqHHV0gKdxaptt5+Ms9dobPmQvVhjrne3LCMdhZTNs1ksa+E15EFGxeL3oo9quvH
 EFNrXL/YYjX3Xg==;
Received: from acorallo by fencepost.gnu.org with local (Exim 4.90_1)
 (envelope-from <acorallo@HIDDEN>)
 id 1tRpqx-0005YS-70; Sun, 29 Dec 2024 04:44:55 -0500
From: Andrea Corallo <acorallo@HIDDEN>
In-Reply-To: <865xn4ul9t.fsf@HIDDEN> (Eli Zaretskii's message of "Sat, 28 Dec
 2024 12:58:22 +0200")
References: <0446a656-1fa2-4160-a8ba-69c060a52589@HIDDEN>
 <yp15xnpg8fl.fsf@HIDDEN> <865xn4ul9t.fsf@HIDDEN>
Date: Sun, 29 Dec 2024 04:44:55 -0500
Message-ID: <yp14j2m9620.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: -2.3 (--)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

Eli Zaretskii <eliz@HIDDEN> writes:

>> Cc: 74771 <at> debbugs.gnu.org
>> From: Andrea Corallo <acorallo@HIDDEN>
>> Date: Wed, 11 Dec 2024 17:29:34 -0500
>>=20
>> Eric Marsden <eric.marsden@HIDDEN> writes:
>>=20
>> > Hi,
>> >
>> > With the attached source file, Emacs miscompiles the struct predicate =
such
>> > that a repeated call to the predicate on a non-struct object returns t.
>> > This occurs with current HEAD on Linux/AMD64, but not on the Emacs 30.=
0.92
>> > pretest. It does not occur when the lexical binding cookie is not pres=
ent.
>> >
>> > % /opt/emacs/bin/emacs -Q --batch --eval "(load (native-compile \"/tmp=
/bug.el\"))" -f run
>> > Loading /home/emarsden/.emacs.d/eln-cache/31.0.50-c021c983/bug-59c4b27=
c-c70072f9.eln (native compiled elisp)...
>> > Running in GNU Emacs 31.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Versi=
on 3.24.43, cairo version 1.18.2)
>> > =C2=A0of 2024-12-09
>> > is? nil
>> > is? t=C2=A0=C2=A0 ;; expecting nil
>> > bar: 111
>> >
>> > ;;;   -*- lexical-binding: t -*-
>> > ;;
>> > ;; /opt/emacs/bin/emacs -Q --batch -L . --eval "(load (native-compile =
\"/tmp/bug.el\"))" -f run
>> >
>> > (require 'cl-lib)
>> >
>> > (cl-defstruct foobles bar baz)
>> >
>> > (defun bug (foo)
>> >   (message "is? %s" (foobles-p foo))
>> >   (message "is? %s" (foobles-p foo))
>> >   (message "bar: %s" (foobles-bar foo)))
>> >
>> > (defun run ()
>> >   (message "Running in %s" (version))
>> >   (let ((foo "foo"))
>> >     (bug foo)))
>>=20
>> Hi Eric,
>>=20
>> thanks for the report, I'll look at this in the coming days.
>
> Any progress here?

Not so far, I'm on holiday this days so I don't have much time for
coding, it's in my todo list tho.

  Andrea




Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#74771: Native compilation bug with struct predicates when lexical binding enabled (HEAD)
Resent-From: Pip Cet <pipcet@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Wed, 08 Jan 2025 11:52:02 +0000
Resent-Message-ID: <handler.74771.B74771.173633708026218 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 74771
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: Andrea Corallo <acorallo@HIDDEN>
Cc: Eli Zaretskii <eliz@HIDDEN>, eric.marsden@HIDDEN, 74771 <at> debbugs.gnu.org
Received: via spool by 74771-submit <at> debbugs.gnu.org id=B74771.173633708026218
          (code B ref 74771); Wed, 08 Jan 2025 11:52:02 +0000
Received: (at 74771) by debbugs.gnu.org; 8 Jan 2025 11:51:20 +0000
Received: from localhost ([127.0.0.1]:46208 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tVUal-0006on-WD
	for submit <at> debbugs.gnu.org; Wed, 08 Jan 2025 06:51:20 -0500
Received: from mail-10628.protonmail.ch ([79.135.106.28]:52871)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <pipcet@HIDDEN>)
 id 1tVUaj-0006oK-51
 for 74771 <at> debbugs.gnu.org; Wed, 08 Jan 2025 06:51:19 -0500
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com;
 s=protonmail3; t=1736337070; x=1736596270;
 bh=O7aUALWHAK/Zc6/ii8aO3WSl5OfYodSyBkyteYaPAbc=;
 h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References:
 Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID:
 Message-ID:BIMI-Selector:List-Unsubscribe:List-Unsubscribe-Post;
 b=qtzOGvam6qjRvtyUjhHYtADbaOTjYj6LdU32xPcpbPrhUEuQDhmk7UaVlmrN7ThyC
 s7ie4yNw9nyleqkTD6z3SVExz/UWSPz5+uqUBUscLRsHhn3QG8jlnewCKSvKG/kBDI
 qEMLO5jwdSmB22+ZJVnah53fzks0VR3e1Mw2xDCv2R+sFU6cSmhVAJnM6V6Qj/uHX4
 SlzUIa+2LLDrEjJqeeCEE4qNIAKzwsCRqZxoUdkxQbSkYc3mRmhJGN0vOFPv8a+fK6
 WZHkisIeRONRgJnRtdumtSvLSXgblIVW+AER9oqCrK4/csTxMi6UGryh7Gz1N5XtYG
 mCY64tPMT9MBg==
Date: Wed, 08 Jan 2025 11:51:07 +0000
From: Pip Cet <pipcet@HIDDEN>
Message-ID: <871pxdfrrr.fsf@HIDDEN>
In-Reply-To: <yp14j2m9620.fsf@HIDDEN>
References: <0446a656-1fa2-4160-a8ba-69c060a52589@HIDDEN>
 <yp15xnpg8fl.fsf@HIDDEN> <865xn4ul9t.fsf@HIDDEN>
 <yp14j2m9620.fsf@HIDDEN>
Feedback-ID: 112775352:user:proton
X-Pm-Message-ID: c65040cd37f5acea461b30c554b179eafdba2031
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: 0.0 (/)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

"Andrea Corallo" <acorallo@HIDDEN> writes:

> Eli Zaretskii <eliz@HIDDEN> writes:
>
>>> Cc: 74771 <at> debbugs.gnu.org
>>> From: Andrea Corallo <acorallo@HIDDEN>
>>> Date: Wed, 11 Dec 2024 17:29:34 -0500
>>>
>>> Eric Marsden <eric.marsden@HIDDEN> writes:
>>>
>>> > Hi,
>>> >
>>> > With the attached source file, Emacs miscompiles the struct predicate=
 such
>>> > that a repeated call to the predicate on a non-struct object returns =
t.
>>> > This occurs with current HEAD on Linux/AMD64, but not on the Emacs 30=
.0.92
>>> > pretest. It does not occur when the lexical binding cookie is not pre=
sent.
>>> >
>>> > % /opt/emacs/bin/emacs -Q --batch --eval "(load (native-compile \"/tm=
p/bug.el\"))" -f run
>>> > Loading /home/emarsden/.emacs.d/eln-cache/31.0.50-c021c983/bug-59c4b2=
7c-c70072f9.eln (native compiled elisp)...
>>> > Running in GNU Emacs 31.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Vers=
ion 3.24.43, cairo version 1.18.2)
>>> > =C2=A0of 2024-12-09
>>> > is? nil
>>> > is? t=C2=A0=C2=A0 ;; expecting nil
>>> > bar: 111
>>> >
>>> > ;;;   -*- lexical-binding: t -*-
>>> > ;;
>>> > ;; /opt/emacs/bin/emacs -Q --batch -L . --eval "(load (native-compile=
 \"/tmp/bug.el\"))" -f run
>>> >
>>> > (require 'cl-lib)
>>> >
>>> > (cl-defstruct foobles bar baz)
>>> >
>>> > (defun bug (foo)
>>> >   (message "is? %s" (foobles-p foo))
>>> >   (message "is? %s" (foobles-p foo))
>>> >   (message "bar: %s" (foobles-bar foo)))
>>> >
>>> > (defun run ()
>>> >   (message "Running in %s" (version))
>>> >   (let ((foo "foo"))
>>> >     (bug foo)))
>>>
>>> Hi Eric,
>>>
>>> thanks for the report, I'll look at this in the coming days.
>>
>> Any progress here?
>
> Not so far, I'm on holiday this days so I don't have much time for
> coding, it's in my todo list tho.

No activity in a while, so I tried reproducing this: bug's still there.

Can you repeat for me what

(assume #s(comp-mvar (t) nil nil nil nil nil) (not #s(comp-mvar (foobles) n=
il nil nil nil nil)))

is supposed to mean?

To me, it appears to mean "the value of the first mvar is different from
the value of the second mvar, which is of type foobles".  This doesn't
say anything about the type of the first mvar, assuming there is more
than one value of the foobles type; if this is the correct
interpretation, we need to stop copying the typeset in this case:

diff --git a/lisp/emacs-lisp/comp-cstr.el b/lisp/emacs-lisp/comp-cstr.el
index 3d46cc8c6ae..5d87ff75703 100644
--- a/lisp/emacs-lisp/comp-cstr.el
+++ b/lisp/emacs-lisp/comp-cstr.el
@@ -1176,14 +1176,11 @@ comp-cstr-value-negation
   "Negate values in SRC setting the result in DST.
 DST is returned."
   (with-comp-cstr-accessors
-    (if (or (valset src) (range src))
-        (setf (typeset dst) ()
-              (valset dst) (valset src)
-              (range dst) (range src)
-              (neg dst) (not (neg src)))
-      (setf (typeset dst) (typeset src)
-            (valset dst) ()
-            (range dst) ()))
+    (and (or (valset src) (range src))
+         (setf (typeset dst) ()
+               (valset dst) (valset src)
+               (range dst) (range src)
+               (neg dst) (not (neg src))))
     dst))
=20
 (defun comp-cstr-negation-make (src)


I see two other possibilities:

1. it means the lhs mvar is of type "foobles", but not identical to the
second mvar.  This is what comp-cstr-negation-make currently assumes.
In this case, comp--add-cond-cstrs should not be emitting this
pseudo-insn for the case in which the lhs mvar is known not to be of
type "foobles", but nothing else is known about its value:

diff --git a/lisp/emacs-lisp/comp.el b/lisp/emacs-lisp/comp.el
index 269eae315e4..d5c512fbdc3 100644
--- a/lisp/emacs-lisp/comp.el
+++ b/lisp/emacs-lisp/comp.el
@@ -2033,11 +2033,7 @@ comp--add-cond-cstrs
        (comp--emit-assume 'and mvar-tested
                          (make--comp-mvar :type (comp-cstr-cl-tag mvar-tag=
))
                          (comp--add-cond-cstrs-target-block b bb2)
-                         nil)
-       (comp--emit-assume 'and mvar-tested
-                         (make--comp-mvar :type (comp-cstr-cl-tag mvar-tag=
))
-                         (comp--add-cond-cstrs-target-block b bb1)
-                         t))
+                         nil))
       (`((set ,(and (pred comp-mvar-p) cmp-res)
               (,(pred comp--call-op-p)
                ,(and (or (pred comp--equality-fun-p)

2. it means the lhs mvar is not of type "foobles".  In this case,
comp-cstr-value-negation should make the lhs mvar have a negated cstr
with type "foobles":

diff --git a/lisp/emacs-lisp/comp-cstr.el b/lisp/emacs-lisp/comp-cstr.el
index 3d46cc8c6ae..03a00123f64 100644
--- a/lisp/emacs-lisp/comp-cstr.el
+++ b/lisp/emacs-lisp/comp-cstr.el
@@ -1183,7 +1183,8 @@ comp-cstr-value-negation
               (neg dst) (not (neg src)))
       (setf (typeset dst) (typeset src)
             (valset dst) ()
-            (range dst) ()))
+            (range dst) ()
+            (neg dst) (not (neg src))))
     dst))
=20
 (defun comp-cstr-negation-make (src)

Note that if (2) is intended, that is a really strange interpretation of
what "not" means: it's negating a cstr (a set of values), not an mvar (a
specific value), so why is the argument an mvar?  We could make this
change, and then try to recover whichever optimizations that disables:

diff --git a/lisp/emacs-lisp/comp.el b/lisp/emacs-lisp/comp.el
index 269eae315e4..bcc0628235a 100644
--- a/lisp/emacs-lisp/comp.el
+++ b/lisp/emacs-lisp/comp.el
@@ -2035,7 +2035,7 @@ comp--add-cond-cstrs
                          (comp--add-cond-cstrs-target-block b bb2)
                          nil)
        (comp--emit-assume 'and mvar-tested
-                         (make--comp-mvar :type (comp-cstr-cl-tag mvar-tag=
))
+                         (comp--type-to-cstr (comp-cstr-cl-tag mvar-tag))
                          (comp--add-cond-cstrs-target-block b bb1)
                          t))
       (`((set ,(and (pred comp-mvar-p) cmp-res)

In any case, please consider documenting the pseudo-insns.
not-eq-to-mvar and not-matching-cstr are two very different things!

Pip






Last modified: Sun, 12 Jan 2025 05:45:02 UTC

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