From unknown Wed Jun 18 22:59:05 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#19417 <19417@debbugs.gnu.org> To: bug#19417 <19417@debbugs.gnu.org> Subject: Status: let, assq-set optimization gone wrong? Reply-To: bug#19417 <19417@debbugs.gnu.org> Date: Thu, 19 Jun 2025 05:59:05 +0000 retitle 19417 let, assq-set optimization gone wrong? reassign 19417 guile submitter 19417 Matt Wette severity 19417 normal tag 19417 notabug thanks From debbugs-submit-bounces@debbugs.gnu.org Sat Dec 20 00:52:20 2014 Received: (at submit) by debbugs.gnu.org; 20 Dec 2014 05:52:20 +0000 Received: from localhost ([127.0.0.1]:52074 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Y2Cxf-0001PM-HS for submit@debbugs.gnu.org; Sat, 20 Dec 2014 00:52:19 -0500 Received: from eggs.gnu.org ([208.118.235.92]:47567) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Y2Cxd-0001PD-7G for submit@debbugs.gnu.org; Sat, 20 Dec 2014 00:52:17 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Y2CxT-0002TS-4k for submit@debbugs.gnu.org; Sat, 20 Dec 2014 00:52:16 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,HTML_MESSAGE autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:39689) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y2CxT-0002TO-1M for submit@debbugs.gnu.org; Sat, 20 Dec 2014 00:52:07 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49263) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y2CxL-0005ex-D6 for bug-guile@gnu.org; Sat, 20 Dec 2014 00:52:06 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Y2CxD-0002Qt-S1 for bug-guile@gnu.org; Sat, 20 Dec 2014 00:51:59 -0500 Received: from vms173019pub.verizon.net ([206.46.173.19]:34339) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y2CxD-0002Qa-LG for bug-guile@gnu.org; Sat, 20 Dec 2014 00:51:51 -0500 Received: from [192.168.2.127] ([71.108.232.238]) by vms173019.mailsrvcs.net (Oracle Communications Messaging Server 7.0.5.32.0 64bit (built Jul 16 2014)) with ESMTPA id <0NGV002529LWCF90@vms173019.mailsrvcs.net> for bug-guile@gnu.org; Fri, 19 Dec 2014 23:51:39 -0600 (CST) X-CMAE-Score: 0 X-CMAE-Analysis: v=2.1 cv=CoYIqc8G c=1 sm=1 tr=0 a=XxAusKNOGYjrkNisIOG4pA==:117 a=oR5dmqMzAAAA:8 a=-9mUelKeXuEA:10 a=A92cGCtB03wA:10 a=pGLkceISAAAA:8 a=KVc9jYcH-drQNWE09MYA:9 a=CjuIK1q_8ugA:10 a=wW-rDSyECJrBCfzv:21 a=_W_S_7VecoQA:10 From: Matt Wette Content-type: multipart/alternative; boundary="Apple-Mail=_5E311C63-B955-4882-BB55-35043840F493" Subject: let, assq-set optimization gone wrong? Date: Fri, 19 Dec 2014 21:51:29 -0800 Message-id: To: bug-guile@gnu.org MIME-version: 1.0 (Mac OS X Mail 7.3 \(1878.6\)) X-Mailer: Apple Mail (2.1878.6) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -5.0 (-----) X-Debbugs-Envelope-To: submit Cc: mwette@alumni.caltech.edu, Panicz Maciej Godek X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.0 (-----) --Apple-Mail=_5E311C63-B955-4882-BB55-35043840F493 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii This was discovered with help from godek.maciek@gmail.com. It seems the variable "l" in the second let below is bound to the value = from the first. I ran into this bug when using syntax-rules with a let/a-list in the = expansion. mwette$ cat bug.scm (let ((l '((a . 1) (b . 2)))) (assq-set! l 'b 99)) (let ((l '((a . 1) (b . 2)))) l) mwette$ guile20 GNU Guile 2.0.11 Copyright (C) 1995-2014 Free Software Foundation, Inc. Guile comes with ABSOLUTELY NO WARRANTY; for details type `,show w'. This program is free software, and you are welcome to redistribute it under certain conditions; type `,show c' for details. Enter `,help' for help. scheme@(guile-user)> (load "bug.scm") $1 =3D ((a . 1) (b . 99)) scheme@(guile-user)> %guile-build-info $2 =3D ((buildstamp . "2014-10-07 02:36:10") (CFLAGS . " = -I/opt/local/include -D_THREAD_SAFE ") (LIBS . "-L/opt/local/lib -lm ") = (libguileinterface . "29:2:7") (guileversion . "2.0.11") (extensiondir . = "/opt/local/lib/guile/2.0/extensions") (pkgincludedir . = "/opt/local/include/guile") (pkglibdir . "/opt/local/lib/guile") = (pkgdatadir . "/opt/local/share/guile") (includedir . = "/opt/local/include") (mandir . "/opt/local/share/man") (infodir . = "/opt/local/share/info") (ccachedir . "/opt/local/lib/guile/2.0/ccache") = (libdir . "/opt/local/lib") (localstatedir . "/opt/local/var") = (sharedstatedir . "/opt/local/com") (sysconfdir . "/opt/local/etc") = (datadir . "/opt/local/share") (libexecdir . "/opt/local/libexec") = (sbindir . "/opt/local/sbin") (bindir . "/opt/local/bin") (exec_prefix . = "/opt/local") (prefix . "/opt/local") (top_srcdir . = "/opt/local/var/macports/build/_Users_mwette_proj_macports_ports_lang_guil= e20/guile20/work/guile-2.0.11") (srcdir . = "/opt/local/var/macports/build/_Users_mwette_proj_macports_ports_lang_guil= e20/guile20/work/guile-2.0.11/libguile")) --Apple-Mail=_5E311C63-B955-4882-BB55-35043840F493 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=us-ascii This = was discovered with help from godek.maciek@gmail.com.
It = seems the variable "l" in the second let below is bound to the value = from the first.
I ran into this bug when using syntax-rules = with a let/a-list in the expansion.

mwette$ cat = bug.scm
(let ((l '((a . 1) (b . 2)))) (assq-set! l 'b 99))
(let ((l = '((a . 1) (b . 2)))) l)
mwette$ guile20
GNU Guile 2.0.11
Copyright = (C) 1995-2014 Free Software Foundation, Inc.

Guile comes with ABSOLUTELY NO WARRANTY; for = details type `,show w'.
This program is free software, and you are welcome = to redistribute it
under certain conditions; type `,show c' for = details.

Enter `,help' for help.
scheme@(guile-user)> (load "bug.scm")
$1 =3D ((a . = 1) (b . 99))

scheme@(guile-user)> %guile-build-info
$2 =3D ((buildstamp . "2014-10-07 02:36:10") (CFLAGS . " = -I/opt/local/include -D_THREAD_SAFE ") (LIBS . "-L/opt/local/lib  = -lm ") (libguileinterface . "29:2:7") (guileversion . "2.0.11") = (extensiondir . "/opt/local/lib/guile/2.0/extensions") (pkgincludedir . = "/opt/local/include/guile") (pkglibdir . "/opt/local/lib/guile") = (pkgdatadir . "/opt/local/share/guile") (includedir . = "/opt/local/include") (mandir . "/opt/local/share/man") (infodir . = "/opt/local/share/info") (ccachedir . "/opt/local/lib/guile/2.0/ccache") = (libdir . "/opt/local/lib") (localstatedir . "/opt/local/var") = (sharedstatedir . "/opt/local/com") (sysconfdir . "/opt/local/etc") = (datadir . "/opt/local/share") (libexecdir . "/opt/local/libexec") = (sbindir . "/opt/local/sbin") (bindir . "/opt/local/bin") (exec_prefix . = "/opt/local") (prefix . "/opt/local") (top_srcdir . = "/opt/local/var/macports/build/_Users_mwette_proj_macports_ports_lang_guil= e20/guile20/work/guile-2.0.11") (srcdir . = "/opt/local/var/macports/build/_Users_mwette_proj_macports_ports_lang_guil= e20/guile20/work/guile-2.0.11/libguile"))

= --Apple-Mail=_5E311C63-B955-4882-BB55-35043840F493-- From debbugs-submit-bounces@debbugs.gnu.org Sat Dec 20 09:45:11 2014 Received: (at 19417) by debbugs.gnu.org; 20 Dec 2014 14:45:11 +0000 Received: from localhost ([127.0.0.1]:52240 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Y2LHL-0007o8-3H for submit@debbugs.gnu.org; Sat, 20 Dec 2014 09:45:11 -0500 Received: from vms173017pub.verizon.net ([206.46.173.17]:12403) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Y2LHH-0007nz-Tj for 19417@debbugs.gnu.org; Sat, 20 Dec 2014 09:45:08 -0500 Received: from [192.168.2.127] ([71.108.232.238]) by vms173017.mailsrvcs.net (Oracle Communications Messaging Server 7.0.5.32.0 64bit (built Jul 16 2014)) with ESMTPA id <0NGV00GCIYARX530@vms173017.mailsrvcs.net> for 19417@debbugs.gnu.org; Sat, 20 Dec 2014 08:44:52 -0600 (CST) X-CMAE-Score: 0 X-CMAE-Analysis: v=2.1 cv=B94OC1pJ c=1 sm=1 tr=0 a=XxAusKNOGYjrkNisIOG4pA==:117 a=kj9zAlcOel0A:10 a=oR5dmqMzAAAA:8 a=-9mUelKeXuEA:10 a=A92cGCtB03wA:10 a=FhXY8Wui_iBJtlbHYfAA:9 a=CjuIK1q_8ugA:10 a=PONa5_iCkFYA:10 a=IfFX-06pNyMA:10 a=WzR0aOLg04EA:10 a=vHbikTMChicA:10 From: Matt Wette Content-type: text/plain; charset=us-ascii Content-transfer-encoding: quoted-printable Subject: oops - may not be a bug Message-id: <35E62B15-EE07-432B-9717-2926359C346B@alumni.caltech.edu> Date: Sat, 20 Dec 2014 06:44:50 -0800 To: 19417@debbugs.gnu.org MIME-version: 1.0 (Mac OS X Mail 7.3 \(1878.6\)) X-Mailer: Apple Mail (2.1878.6) X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 19417 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) I have been told this has to do with '((a . 1) (b . 1)) being a literal. = I'm guessing guile caches this and it get then mutated. From debbugs-submit-bounces@debbugs.gnu.org Mon Dec 22 02:04:54 2014 Received: (at 19417) by debbugs.gnu.org; 22 Dec 2014 07:04:54 +0000 Received: from localhost ([127.0.0.1]:54195 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Y2x30-0004Jk-0y for submit@debbugs.gnu.org; Mon, 22 Dec 2014 02:04:54 -0500 Received: from world.peace.net ([50.252.239.5]:58770) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Y2x2w-0004JW-Ju; Mon, 22 Dec 2014 02:04:51 -0500 Received: from [10.1.10.10] (helo=yeeloong.lan) by world.peace.net with esmtpsa (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.72) (envelope-from ) id 1Y2x2q-0003SJ-3h; Mon, 22 Dec 2014 02:04:44 -0500 From: Mark H Weaver To: Matt Wette Subject: Re: bug#19417: oops - may not be a bug References: <35E62B15-EE07-432B-9717-2926359C346B@alumni.caltech.edu> Date: Mon, 22 Dec 2014 02:02:44 -0500 In-Reply-To: <35E62B15-EE07-432B-9717-2926359C346B@alumni.caltech.edu> (Matt Wette's message of "Sat, 20 Dec 2014 06:44:50 -0800") Message-ID: <87mw6g1817.fsf@yeeloong.lan> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 19417 Cc: 19417@debbugs.gnu.org, request@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) tags 19417 + notabug close 19417 thanks Matt Wette writes: > I have been told this has to do with '((a . 1) (b . 1)) being a > literal. I'm guessing guile caches this and it get then mutated. Right. As explained on guile-user, mutating literal data is not permitted and leads to unspecified behavior. Our compiler aggressively shares data between literals in the same compilation unit. Mark From debbugs-submit-bounces@debbugs.gnu.org Mon Dec 22 02:10:42 2014 Received: (at request) by debbugs.gnu.org; 22 Dec 2014 07:10:42 +0000 Received: from localhost ([127.0.0.1]:54205 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Y2x8Z-0004T9-U6 for submit@debbugs.gnu.org; Mon, 22 Dec 2014 02:10:41 -0500 Received: from world.peace.net ([50.252.239.5]:58776) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Y2x8X-0004Sy-IX; Mon, 22 Dec 2014 02:10:37 -0500 Received: from [10.1.10.10] (helo=yeeloong.lan) by world.peace.net with esmtpsa (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.72) (envelope-from ) id 1Y2x8Q-0003UB-CB; Mon, 22 Dec 2014 02:10:30 -0500 From: Mark H Weaver To: Panicz Maciej Godek Subject: Re: bug#19415: Compiler shares storage for assoc-lists even if some of them are mutated References: Date: Mon, 22 Dec 2014 02:08:31 -0500 In-Reply-To: (Panicz Maciej Godek's message of "Sat, 20 Dec 2014 00:53:11 +0100") Message-ID: <87ioh417rk.fsf@yeeloong.lan> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: request Cc: request@debbugs.gnu.org, 19415@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) tags 19415 + notabug close 19415 merge 19415 19417 thanks Panicz Maciej Godek writes: > This bug was traced by Matt Wette and described here: > > http://lists.gnu.org/archive/html/guile-user/2014-12/msg00023.html > > In short, the bug manifests itself when at least two consecutive let > forms are used with an assoc list argument which starts with identical > elements, and the first appearance gets mutated before the second: > > (begin > (let ((l '((a . X)(b . Y)(c . 7)))) > (assoc-set! l 'b 'Z)) > (let ((l '((a . X)(b . Y)))) > l)) > ===> ((a . X) (b . Z)) > > The issue is known to appear in guile 2.0.11 and 2.0.5 As later explained on guile-user, mutating literal data is not permitted in scheme and leads to unspecified behavior. Our compiler aggressively shares data between literals in the same compilation unit. See for a related wishlist item. Thanks, Mark From unknown Wed Jun 18 22:59:05 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Mon, 19 Jan 2015 12:24:03 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator