From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Pip Cet Newsgroups: gmane.emacs.bugs Subject: bug#46670: 28.0.50; [feature/native-comp] possible miscompilation affecting lsp-mode Date: Sun, 21 Feb 2021 11:51:22 +0000 Message-ID: References: <87a6ry46uc.fsf@collares.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="0000000000000b239405bbd750a7" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="16820"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 46670@debbugs.gnu.org To: Mauricio Collares Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Feb 21 12:54:37 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lDnJt-0004Hd-7l for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 21 Feb 2021 12:54:37 +0100 Original-Received: from localhost ([::1]:40722 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lDnJs-00045r-1C for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 21 Feb 2021 06:54:36 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:34720) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lDnIM-0003fM-TV for bug-gnu-emacs@gnu.org; Sun, 21 Feb 2021 06:53:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:42073) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lDnIM-0002A3-Lv for bug-gnu-emacs@gnu.org; Sun, 21 Feb 2021 06:53:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lDnIM-0004pV-JB for bug-gnu-emacs@gnu.org; Sun, 21 Feb 2021 06:53:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Pip Cet Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 21 Feb 2021 11:53:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 46670 X-GNU-PR-Package: emacs Original-Received: via spool by 46670-submit@debbugs.gnu.org id=B46670.161390832718427 (code B ref 46670); Sun, 21 Feb 2021 11:53:02 +0000 Original-Received: (at 46670) by debbugs.gnu.org; 21 Feb 2021 11:52:07 +0000 Original-Received: from localhost ([127.0.0.1]:53619 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lDnHS-0004n9-Ry for submit@debbugs.gnu.org; Sun, 21 Feb 2021 06:52:07 -0500 Original-Received: from mail-oi1-f173.google.com ([209.85.167.173]:38508) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lDnHQ-0004md-IA for 46670@debbugs.gnu.org; Sun, 21 Feb 2021 06:52:06 -0500 Original-Received: by mail-oi1-f173.google.com with SMTP id h17so11161027oih.5 for <46670@debbugs.gnu.org>; Sun, 21 Feb 2021 03:52:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=NhHpfM6+SwMHueDePuBPH3EE+SZPcyTfOMrMFX4xOOA=; b=q5muSwwhhyXlubJzsjuYRr3ICfYjTEmMMY4BomrjFeYFKWgFkLL7cRFIOJOzdCALrw In5mg75qJe+3WAS/KiY+DroiPhVzEBro5l3xfYUVXKPvjPjeSYfV5rbmdEm/72DheRTx h6CMLRz/ByjRv/jY2gBkdA9lHAFCGZ2z5BNZHUgvW/b4P/ehI4WXFHHbQriYwUTKJ17u AJhl2I9Gpu+QOOVRyqR3t7jjK38deR9zNWT2qs/yYy4HVAvoOCSsRUsEMl4P+XJg3DTd RIvX+6+QJAnCwVBtTIAUA3k3XT0V+qAG9t2h3DaraJoX1IY4K96PE9fwQlvmE298czfG g51A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=NhHpfM6+SwMHueDePuBPH3EE+SZPcyTfOMrMFX4xOOA=; b=aIoiHxft9T7FCYhjtYOL7K63xJJnbTjIKhRSmfIgiOOoKtohj/ndVb0J73lilG89eg //kaJCAuVC387tMg9oCf4xXYxYXDt4+0axRk8mYcYlqQ7mcllDVplD8xDQeN9bqxb9Ds ntK9H5sN45YcsAbaLP5ZQLzI5pncY9Cp3asgdzQfJt7UpqPx9NC0EZ4QBbBG5tWh/SOA ShzzoCqmBB2OVZYxvrZYmB+pFuV1b//bHe2Mz6HOhUazBmcWAhWRbb9w8IM4hWvMvNG2 DS6MCWniVMtkEkNY50oqwgH5LXjBBjokgv9sD4xyhSO3VNxd+M/D55W7L3L4hFg8XJav J80g== X-Gm-Message-State: AOAM533SAL9hyHM1BuToEA5srul6id9vQ92M+uK4UAbMSuedZcBFH2cm 1H4fz2uNFP60UH3+l7qIZiofm9ZuDBIqIiacMRdGA77y1Ns= X-Google-Smtp-Source: ABdhPJxDtDdk5oDZDK2uhqf6pdzwg7M8o8ZcObUUPz9itZ4NJnNbxxzK7zN9HKU7VDxcIWVZLH1OEvQkcKDACBA+t+A= X-Received: by 2002:aca:4c5:: with SMTP id 188mr8337309oie.44.1613908318817; Sun, 21 Feb 2021 03:51:58 -0800 (PST) In-Reply-To: <87a6ry46uc.fsf@collares.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:200484 Archived-At: --0000000000000b239405bbd750a7 Content-Type: text/plain; charset="UTF-8" On Sun, Feb 21, 2021 at 12:14 AM Mauricio Collares 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. --0000000000000b239405bbd750a7 Content-Type: text/x-patch; charset="US-ASCII"; name="0001-native-comp-Fix-constraint-for-assume-x-and-a-b-Bug-.patch" Content-Disposition: attachment; filename="0001-native-comp-Fix-constraint-for-assume-x-and-a-b-Bug-.patch" Content-Transfer-Encoding: base64 Content-ID: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