From: Pip Cet <pipcet@gmail.com>
To: Mauricio Collares <mauricio@collares.org>
Cc: 46670@debbugs.gnu.org
Subject: bug#46670: 28.0.50; [feature/native-comp] possible miscompilation affecting lsp-mode
Date: Sun, 21 Feb 2021 11:51:22 +0000 [thread overview]
Message-ID: <CAOqdjBe55v0oGtD+qN8PcitV0tqoNCGLOco5y8y4GsG8nU6yaw@mail.gmail.com> (raw)
In-Reply-To: <87a6ry46uc.fsf@collares.org>
[-- Attachment #1: Type: text/plain, Size: 1827 bytes --]
On Sun, Feb 21, 2021 at 12:14 AM Mauricio Collares
<mauricio@collares.org> wrote:
> This was found by Anthony Cowley, who isolated the exact function in
> lsp-mode that was misbehaving. I verified that I could reproduce this
> findings, and then I removed surrounding context to obtain a minimized
> testcase. If this fails to reproduce, it's entirely my fault.
>
> Steps to reproduce:
>
> 1) Put this in minimized.el:
>
> ;;; -*- lexical-binding: t; -*-
>
> (defun minimized--look-back (s)
> (and (equal (buffer-substring-no-properties (- (point) (length s)) (point))
> s)
> s))
>
> (defun minimized-go ()
> (interactive)
> (message (minimized--look-back ".")))
>
> (provide 'minimized)
>
> 2) Type "." in a buffer and then run minimized-go with the point after
> the period. This prints back "." in the minibuffer if the code's
> interpreted but not if it's native-compiled.
>
> Note that removing the "lexical-binding: t" line makes the bug not
> reproduce. Replacing "(- (point) (length s))" by "(1- (point))" also
> makes the bug disappear.
I can reproduce this with this code:
(funcall
(let ((comp-verbose 3) (comp-debug 3))
(native-compile `(lambda (s) (and (equal
(buffer-substring-no-properties (- (point) (length s)) (point)) s)
s))))
")")
I think there's some confusion in comp-fwprop-insn between (and) as a
logical operator and (and) as a pcase operator. The latter means a
variable's constraint must be in the intersection of all argument
types, but the former only implies that the variable constraint is
somewhere in the union of the argument constraints [1].
Does the attached patch help? Andrea, is my analysis correct?
Pip
[1] - note that we emit (assume a (and b c)) for (setq a (and c b))
under some circumstances, so it would be incorrect to use only c's
constraint.
[-- Attachment #2: 0001-native-comp-Fix-constraint-for-assume-x-and-a-b-Bug-.patch --]
[-- Type: text/x-patch, Size: 902 bytes --]
From bd3a823b827c9394c11aae63dc3fa81098699296 Mon Sep 17 00:00:00 2001
From: Pip Cet <pipcet@gmail.com>
Date: Sun, 21 Feb 2021 11:44:27 +0000
Subject: [PATCH] [native-comp] Fix constraint for (assume x (and a b))
(Bug#46670)
* lisp/emacs-lisp/comp.el (comp-fwprop-insn): Use comp-cstr-union, not
comp-cstr-intersection.
---
lisp/emacs-lisp/comp.el | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lisp/emacs-lisp/comp.el b/lisp/emacs-lisp/comp.el
index 4036080976546..965121657f601 100644
--- a/lisp/emacs-lisp/comp.el
+++ b/lisp/emacs-lisp/comp.el
@@ -3059,7 +3059,7 @@ comp-fwprop-insn
(`(assume ,lval (,kind . ,operands))
(cl-case kind
(and
- (apply #'comp-cstr-intersection lval operands))
+ (apply #'comp-cstr-union lval operands))
(not
;; Prevent double negation!
(unless (comp-cstr-neg (car operands))
--
2.30.0
next prev parent reply other threads:[~2021-02-21 11:51 UTC|newest]
Thread overview: 50+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-21 0:12 bug#46670: 28.0.50; [feature/native-comp] possible miscompilation affecting lsp-mode Mauricio Collares
2021-02-21 11:51 ` Pip Cet [this message]
2021-02-21 11:56 ` Pip Cet
2021-02-21 21:03 ` Andrea Corallo via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-02-21 22:46 ` Pip Cet
2021-02-22 9:37 ` Andrea Corallo via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-02-22 10:04 ` Pip Cet
2021-02-22 10:25 ` Pip Cet
2021-02-22 11:23 ` Andrea Corallo via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-02-22 12:11 ` Pip Cet
2021-02-22 13:12 ` Andrea Corallo via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-02-23 7:59 ` Pip Cet
2021-02-23 9:04 ` Andrea Corallo via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-02-23 23:26 ` Andrea Corallo via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-02-24 2:10 ` Mauricio Collares
2021-02-24 8:22 ` Andrea Corallo via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-02-23 19:09 ` Pip Cet
2021-02-23 23:36 ` Andrea Corallo via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-02-24 4:31 ` Pip Cet
2021-02-24 9:04 ` Andrea Corallo via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-02-24 9:28 ` Pip Cet
2021-02-24 9:42 ` Andrea Corallo via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-02-24 9:46 ` Pip Cet
2021-02-24 10:06 ` Andrea Corallo via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-02-25 12:41 ` Pip Cet
2021-02-25 14:58 ` Eli Zaretskii
2021-02-25 15:14 ` Pip Cet
2021-02-25 15:31 ` Eli Zaretskii
2021-02-25 16:56 ` Andrea Corallo via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-02-25 20:59 ` Pip Cet
2021-02-26 19:33 ` Andrea Corallo via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-02-26 20:30 ` Pip Cet
2021-02-26 20:44 ` Andrea Corallo via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-02-26 20:11 ` Eli Zaretskii
2021-02-26 20:32 ` Pip Cet
2021-02-27 5:06 ` Pip Cet
2021-02-27 7:49 ` Eli Zaretskii
2021-02-27 9:39 ` Pip Cet
2021-02-27 10:24 ` Eli Zaretskii
2021-02-27 12:39 ` Pip Cet
2021-02-27 13:30 ` Eli Zaretskii
2021-02-27 17:15 ` Pip Cet
2021-02-27 18:40 ` Eli Zaretskii
2021-02-28 8:14 ` Pip Cet
2021-03-01 5:24 ` Richard Stallman
2021-03-01 6:40 ` Pip Cet
2021-02-22 11:16 ` Andrea Corallo via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-02-23 9:07 ` Pip Cet
2021-02-23 22:55 ` Andrea Corallo via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-02-24 7:00 ` Pip Cet
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAOqdjBe55v0oGtD+qN8PcitV0tqoNCGLOco5y8y4GsG8nU6yaw@mail.gmail.com \
--to=pipcet@gmail.com \
--cc=46670@debbugs.gnu.org \
--cc=mauricio@collares.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).