GNU bug report logs - #76546
30.1; Native compilation is corrupting lambdas/closures stored in variables after some time

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Reported by: Christian Johansson <christian@HIDDEN>; dated Tue, 25 Feb 2025 10:30:02 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.

Message received at 76546 <at> debbugs.gnu.org:


Received: (at 76546) by debbugs.gnu.org; 26 Apr 2025 13:09:29 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Apr 26 09:09:29 2025
Received: from localhost ([127.0.0.1]:59362 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1u8fHc-0004vz-UW
	for submit <at> debbugs.gnu.org; Sat, 26 Apr 2025 09:09:29 -0400
Received: from mailrelay2-1.pub.mailoutpod3-cph3.one.com
 ([2a02:2350:5:421::1]:33903)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <christian@HIDDEN>) id 1u8fHY-0004vQ-Gd
 for 76546 <at> debbugs.gnu.org; Sat, 26 Apr 2025 09:09:26 -0400
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1745672958;
 x=1746277758; d=cvj.se; s=rsa2;
 h=to:in-reply-to:cc:references:message-id:date:subject:mime-version:from:
 content-transfer-encoding:content-type:from;
 bh=SXbTsELxgYgoYg1pJChzjqXRMxu2hw3NlKl9kOGkE4Y=;
 b=QFa69Bp/VY+E4gOnoICFgGBIYNrc/T5nmSMvU7HZn6KEgRfuyFb4l8Qii6II2nVCDPVddLqRaj6f0
 b0GrtEhqMTCRgwOHoUjFtM3qzacHuPw9Hrtp7gABJW45RxTD9UupQasfU5oFSWG7yw3gq6Ikld+Zhm
 PSMwnJSMDitOhqupdc1ieS6B8gl4lhTruy52r3/oTKzdSgRAJ1kvqRf6cZuBL9DZ+E49HNhu/DBJO8
 WAskreoxrObmClEQm5ClfzI1KRTBzLm6KZh6AeCW2z39dE5C4lOHjP6aUoonITlasaeKPzLAnrq7pd
 CKofIwA4o5VYtVITtYENtdow6oBnibQ==
DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; t=1745672958;
 x=1746277758; d=cvj.se; s=ed2;
 h=to:in-reply-to:cc:references:message-id:date:subject:mime-version:from:
 content-transfer-encoding:content-type:from;
 bh=SXbTsELxgYgoYg1pJChzjqXRMxu2hw3NlKl9kOGkE4Y=;
 b=mEV0W4b/xIKywe3PfBdGcQKOO4mn+qMYFb5ZBAdM7pMYMR7ywwuR45Vex9JSEgWHR2Zv10CKis5Mj
 IZrYTTfAQ==
X-HalOne-ID: a7feec0a-229f-11f0-abd0-b37c246f863f
Received: from smtpclient.apple (c-84-217-176-184.bbcust.telenor.se
 [84.217.176.184])
 by mailrelay2.pub.mailoutpod3-cph3.one.com (Halon) with ESMTPSA
 id a7feec0a-229f-11f0-abd0-b37c246f863f;
 Sat, 26 Apr 2025 13:09:18 +0000 (UTC)
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
From: Christian Johansson <christian@HIDDEN>
Mime-Version: 1.0 (1.0)
Subject: Re: bug#76546: 30.1;
 Native compilation is corrupting lambdas/closures stored in variables
 after some time
Date: Sat, 26 Apr 2025 15:09:07 +0200
Message-Id: <E01C2229-2B97-430B-9CE3-81C949A1D917@HIDDEN>
References: <865xiruowq.fsf@HIDDEN>
In-Reply-To: <865xiruowq.fsf@HIDDEN>
To: Eli Zaretskii <eliz@HIDDEN>
X-Mailer: iPhone Mail (22D82)
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 76546
Cc: 76546 <at> debbugs.gnu.org, acorallo@HIDDEN
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 (-)

Yes maybe, it was apparent from the error message that the function had unex=
pected data and trying to print it crashed Emacs.. I will check for an old l=
og

But this error has been present for many years so it is not a new thing, I s=
olved it by not byte compilling some files

> Eli Zaretskii <eliz@HIDDEN> kirjoitti 2025-04-26 kello 13.45:
>=20
> =EF=BB=BF
>>=20
>> Cc: 76546 <at> debbugs.gnu.org, acorallo@HIDDEN
>> Date: Tue, 15 Apr 2025 11:38:34 +0300
>> From: Eli Zaretskii <eliz@HIDDEN>
>>=20
>>> From: Christian Johansson <christian@HIDDEN>
>>> Date: Tue, 15 Apr 2025 09:58:07 +0200
>>> Cc: Eli Zaretskii <eliz@HIDDEN>, 76546 <at> debbugs.gnu.org
>>>=20
>>> I have one issue that is reproducible but only after a couple of days of=
 Emacs running and exahausting the memory, in that case the lambda stored in=
 variable becomes binary and printing it crashes Emacs
>>=20
>> If the value cannot be printed, how do you know that it is binary?
>>=20
>> Could you perhaps run Emacs under GDB, so that when this happens, you
>> could show the value and perhaps invoke some other commands we would
>> like you to try and show the results?
>=20
> Ping!  Any further information or progress with this?




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#76546; Package emacs. Full text available.

Message received at 76546 <at> debbugs.gnu.org:


Received: (at 76546) by debbugs.gnu.org; 26 Apr 2025 11:45:53 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Apr 26 07:45:53 2025
Received: from localhost ([127.0.0.1]:58894 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1u8dyi-0005RZ-Vm
	for submit <at> debbugs.gnu.org; Sat, 26 Apr 2025 07:45:53 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:52882)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <eliz@HIDDEN>) id 1u8dyh-0005RH-Em
 for 76546 <at> debbugs.gnu.org; Sat, 26 Apr 2025 07:45:51 -0400
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 1u8dya-0001jD-23; Sat, 26 Apr 2025 07:45:44 -0400
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=W9634ork/FaUdA2SVpPbyfAkHXmKGDZS4YoVkCCICA0=; b=QjTd6TDTO3rd
 XnMu8kkw1kNj/QKpMweQJUXnwO5WE6R9I6nCgKE5nnIO/ncZIR+QMIf48y3GU3ZSm2ogNemSW6NtF
 tcC+pviEei2+8UQUSr5RuDLqE4oMzr0uabIM7UQa8aROYeD+AFFCzJHZjLVE8oZEMhXAi9ytAnsaR
 9xZ5uxLSqKyo8P+zj2tpTfOoHQUFMyQj6vQdycCaLLWoYN0d5iXcI8LADuHS/ulalTMalX4gr94ZL
 8C/RhfBcnOTsCxtjp1Nn5TOaeI/eGgYGup9ec46bHtc3tpv21dtuT/ez1qZZBtAngf8vzqgdphKYk
 T2/gs+BRO7JBlHeU6B2ZnQ==;
Date: Sat, 26 Apr 2025 14:45:41 +0300
Message-Id: <865xiruowq.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: christian@HIDDEN
In-Reply-To: <86tt6phl9x.fsf@HIDDEN> (message from Eli Zaretskii on Tue, 15
 Apr 2025 11:38:34 +0300)
Subject: Re: bug#76546: 30.1;
 Native compilation is corrupting lambdas/closures stored in variables
 after some time
References: <yp1mscjt66m.fsf@HIDDEN>
 <36576F50-535B-48D3-BEDD-D9E153C31536@HIDDEN> <86tt6phl9x.fsf@HIDDEN>
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 76546
Cc: 76546 <at> debbugs.gnu.org, acorallo@HIDDEN
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: 76546 <at> debbugs.gnu.org, acorallo@HIDDEN
> Date: Tue, 15 Apr 2025 11:38:34 +0300
> From: Eli Zaretskii <eliz@HIDDEN>
> 
> > From: Christian Johansson <christian@HIDDEN>
> > Date: Tue, 15 Apr 2025 09:58:07 +0200
> > Cc: Eli Zaretskii <eliz@HIDDEN>, 76546 <at> debbugs.gnu.org
> > 
> > I have one issue that is reproducible but only after a couple of days of Emacs running and exahausting the memory, in that case the lambda stored in variable becomes binary and printing it crashes Emacs
> 
> If the value cannot be printed, how do you know that it is binary?
> 
> Could you perhaps run Emacs under GDB, so that when this happens, you
> could show the value and perhaps invoke some other commands we would
> like you to try and show the results?

Ping!  Any further information or progress with this?




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#76546; Package emacs. Full text available.

Message received at 76546 <at> debbugs.gnu.org:


Received: (at 76546) by debbugs.gnu.org; 15 Apr 2025 08:38:54 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Apr 15 04:38:54 2025
Received: from localhost ([127.0.0.1]:50564 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1u4bok-0002XS-2A
	for submit <at> debbugs.gnu.org; Tue, 15 Apr 2025 04:38:54 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:59908)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <eliz@HIDDEN>) id 1u4boh-0002XA-04
 for 76546 <at> debbugs.gnu.org; Tue, 15 Apr 2025 04:38:51 -0400
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 1u4boX-0005Tt-HK; Tue, 15 Apr 2025 04:38:41 -0400
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=TcJT8vLSIjC864e45FlcURFk+6oO1R9zmAgqL6BznaE=; b=draJDg2TTXsG
 B30ZH5TOp/3CkgVguGApDuOX7oxZ3rAUYiLm9vqFLrk/2cD0kBlzUAPrj+7ECEeOeT4j0fUwsDhcu
 CKX7s7VjWIX4Bm+5aZVmPKpPAmwJXBqbOOpo8dvnEPPiABbDVq2H/ErjmYMbasLMh+pZKqHZVkb4j
 wU4kCJWNHpP6ZKu6/U/rUj8IYz3WLvFvOqiHbG3fGI06hfPmuBj/3ohGk0SrSDQQ5tfYniCkF6GR1
 GOQq1eVbCI6kEbxsEIpiCzn9fOKZISWx/qcvNus7LG419O+mSjDkCuyaM+uIkyzAydRoA81JC2zJe
 2X6P3ifm9anmyVs7+XE6Uw==;
Date: Tue, 15 Apr 2025 11:38:34 +0300
Message-Id: <86tt6phl9x.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Christian Johansson <christian@HIDDEN>
In-Reply-To: <36576F50-535B-48D3-BEDD-D9E153C31536@HIDDEN> (message from
 Christian Johansson on Tue, 15 Apr 2025 09:58:07 +0200)
Subject: Re: bug#76546: 30.1;
 Native compilation is corrupting lambdas/closures stored in variables
 after some time
References: <yp1mscjt66m.fsf@HIDDEN>
 <36576F50-535B-48D3-BEDD-D9E153C31536@HIDDEN>
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 76546
Cc: 76546 <at> debbugs.gnu.org, acorallo@HIDDEN
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 (---)

> From: Christian Johansson <christian@HIDDEN>
> Date: Tue, 15 Apr 2025 09:58:07 +0200
> Cc: Eli Zaretskii <eliz@HIDDEN>, 76546 <at> debbugs.gnu.org
> 
> I have one issue that is reproducible but only after a couple of days of Emacs running and exahausting the memory, in that case the lambda stored in variable becomes binary and printing it crashes Emacs

If the value cannot be printed, how do you know that it is binary?

Could you perhaps run Emacs under GDB, so that when this happens, you
could show the value and perhaps invoke some other commands we would
like you to try and show the results?




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#76546; Package emacs. Full text available.

Message received at 76546 <at> debbugs.gnu.org:


Received: (at 76546) by debbugs.gnu.org; 15 Apr 2025 07:58:28 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Apr 15 03:58:28 2025
Received: from localhost ([127.0.0.1]:50411 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1u4bBb-0005td-Tw
	for submit <at> debbugs.gnu.org; Tue, 15 Apr 2025 03:58:28 -0400
Received: from mailrelay3-1.pub.mailoutpod3-cph3.one.com
 ([2a02:2350:5:422::1]:38319)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <christian@HIDDEN>) id 1u4bBY-0005tL-IY
 for 76546 <at> debbugs.gnu.org; Tue, 15 Apr 2025 03:58:25 -0400
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1744703898;
 x=1745308698; d=cvj.se; s=rsa2;
 h=to:in-reply-to:cc:references:message-id:date:subject:mime-version:from:
 content-transfer-encoding:content-type:from;
 bh=Yz20cn/GY2eqd0Fp6RhWudKGE90ZLsUMVTppoQrql5I=;
 b=o/+YgXaO0I2jw0N4xVSpiCdzACE/jAjN7xnW96nxD5rgLK8ADxRHZGIG8APTh0yr47m2Xu69t6Efj
 HStKIKFUqduYVetbQJ3YwRfoYi7H00uzwHIGr7GBQV2TXyDxy1e2Hh0d9onAvZTt8RPYm/dVhSbuQe
 miNV4V/p48+oUrlCx5Q3sIn+ZOB1qHH1KhbVfTcYSvtSOhj2ufweOomemKdBeUZ3ZnNzxJd/kR3Ufc
 98IyAQUF3kLU2CJRjcyEVKikDycPcNGmhoMKgcC+NAoeQkoSUohEvRI+whr5a+iwa2yde8BVqRF0E0
 HFqYQfWlXVHd/T+jVN0fb0A3AtM1d/A==
DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; t=1744703898;
 x=1745308698; d=cvj.se; s=ed2;
 h=to:in-reply-to:cc:references:message-id:date:subject:mime-version:from:
 content-transfer-encoding:content-type:from;
 bh=Yz20cn/GY2eqd0Fp6RhWudKGE90ZLsUMVTppoQrql5I=;
 b=Q99P12HB66p3G7icLesNJdKqoeODX8h63unQym6VPsrP4tr3dEvymdSqhXgWpE6enI81RB1zj57GA
 HXk1KJQDQ==
X-HalOne-ID: 63cccd6a-19cf-11f0-8a3c-2b8368a4d5c5
Received: from smtpclient.apple (c-84-217-176-184.bbcust.telenor.se
 [84.217.176.184])
 by mailrelay3.pub.mailoutpod3-cph3.one.com (Halon) with ESMTPSA
 id 63cccd6a-19cf-11f0-8a3c-2b8368a4d5c5;
 Tue, 15 Apr 2025 07:58:17 +0000 (UTC)
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
From: Christian Johansson <christian@HIDDEN>
Mime-Version: 1.0 (1.0)
Subject: Re: bug#76546: 30.1;
 Native compilation is corrupting lambdas/closures stored in variables
 after some time
Date: Tue, 15 Apr 2025 09:58:07 +0200
Message-Id: <36576F50-535B-48D3-BEDD-D9E153C31536@HIDDEN>
References: <yp1mscjt66m.fsf@HIDDEN>
In-Reply-To: <yp1mscjt66m.fsf@HIDDEN>
To: Andrea Corallo <acorallo@HIDDEN>
X-Mailer: iPhone Mail (22D82)
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 76546
Cc: 76546 <at> debbugs.gnu.org, Eli Zaretskii <eliz@HIDDEN>
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 (-)

Hi

The initial issue disappeared by itself without any updates to software, it s=
tarted to happen after Emacs upgrade on two different machines but resolved i=
tself. Must be something related to corrupt storage of byte compiled or nati=
ve compiled code

I have not encountered the issue since but other strange issues like keymap r=
ebinding after some time in a Emacs session

I have one issue that is reproducible but only after a couple of days of Ema=
cs running and exahausting the memory, in that case the lambda stored in var=
iable becomes binary and printing it crashes Emacs

Regards
Christian

> Andrea Corallo <acorallo@HIDDEN> kirjoitti 2025-04-14 kello 12.15:
>=20
> =EF=BB=BFEli Zaretskii <eliz@HIDDEN> writes:
>=20
>>> Date: Tue, 25 Feb 2025 11:27:58 +0100
>>> From: Christian Johansson <christian@HIDDEN>
>>>=20
>>> There is something fishy going on, but it is a very slippery bug, I have=

>>> trouble reproducing it but it started to happen when native compilation
>>> was introduced and it has significantly gotten worse with Emacs 30, I
>>> never happened before native-compilation was introduced.
>>>=20
>>> Maybe you can give me some tips in building a reproducible test case? I
>>> will try to explain what happens. So prior to Emacs 30 there was only
>>> one bug I stumbled upon:
>>>=20
>>> 1. When a lambda is stored in a variable in a lexical scoped file it
>>> stores a closure. After some time when native compilation has done its
>>> magic on the variable you will get an error when you try to output it
>>> like this:
>>> (format "%S" my-native-compiled-variable) and Emacs crashes.
>>>=20
>>> This happened every time my parser-generator library ran for a long time=

>>> and then tried to output a parser file. The only solution to this was to=

>>> not byte-compile the file that contained the lambdas that was later
>>> supposed to be printed to a file, this solution worked but it was a
>>> workaround due to this bug.
>>>=20
>>>=20
>>> 2. After Emacs 30 it seems to corrupt strings with escape sequences
>>> inside lambdas inside variables, like this:
>>>=20
>>> (setq my-lambda (lambda() (looking-at "<\\?=3D")))
>>>=20
>>> After native-compilation has performed its magic on the variable the
>>> function body will become corrupted and it will become a invalid
>>> function body. This happens now to my major my phps-mode, I have
>>> reproduced the error on two machines with Emacs 30 and it has never
>>> occurred before Emacs 30 and there has been no recent changes to the
>>> plugin. If I just eval the function files anew the problem disappears so=

>>> it only happens in compiled files. It however does not happen in
>>> byte-compiled files, only in native compiled files.
>>=20
>> Andrea, any comments or suggestions?
>=20
> I can't reproduce this on master.  I've:
>=20
> test.el:
> =3D=3D=3D=3D=3D=3D
> ;; -*- lexical-binding: t -*-                                             =
          =20
> (setq my-lambda (lambda() (looking-at "<\\?=3D")))
> =3D=3D=3D=3D=3D=3D
>=20
> If I run emacs:
> $ emacs --batch -eval '(progn (load (native-compile "/home/andcor03/test/t=
est.el")) (funcall my-lambda))'
>=20
> Seems to work for me.  Not sure if the reproducer should be something
> different tho.
>=20
>  Andrea




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#76546; Package emacs. Full text available.

Message received at 76546 <at> debbugs.gnu.org:


Received: (at 76546) by debbugs.gnu.org; 14 Apr 2025 09:59:24 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Apr 14 05:59:23 2025
Received: from localhost ([127.0.0.1]:45860 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1u4Gb5-0007We-FP
	for submit <at> debbugs.gnu.org; Mon, 14 Apr 2025 05:59:23 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:35860)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <acorallo@HIDDEN>) id 1u4Gb3-0007WQ-TK
 for 76546 <at> debbugs.gnu.org; Mon, 14 Apr 2025 05:59:22 -0400
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 1u4Gaw-0003ej-QL; Mon, 14 Apr 2025 05:59:14 -0400
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=P1KoU24bZqObAQIFecJnxMYTra0Z8ajHOmCMU0y8PKc=; b=r350BEh0SStdvEavW8yj
 mwdjSDUReeIuIasIvt5yh0R0GQ+ZIvGBWl4kz2H31eATI4JPEADMbOJ/oH0lxDvrpMdCPeVs0TaQx
 8Rkh6kWTeNk9VJoYIuSZ8p0l8Mo/MOCu6mTxrsW8QZiwNwd39zGh84ZBGGSkePBuPkqvccwDTOUDI
 a6RZqRoYaxk8UZhw4E8/Ih+a0IglcGfSQ1SeUkBhRmZMOw0qLM0m0Y/vHqslsvZlNL9tjPsWumvgf
 Tt1YclCYbe7cr3gTr9gMc/8xet2sH/GCgkOIGyWxACsH9lsRxLnqHo7MY98F30evqHGa7I+uXihrb
 TRxrporK1KwexA==;
Received: from acorallo by fencepost.gnu.org with local (Exim 4.90_1)
 (envelope-from <acorallo@HIDDEN>)
 id 1u4Gav-0007Gw-BG; Mon, 14 Apr 2025 05:59:13 -0400
From: Andrea Corallo <acorallo@HIDDEN>
To: Eli Zaretskii <eliz@HIDDEN>
Subject: Re: bug#76546: 30.1; Native compilation is corrupting
 lambdas/closures stored in variables after some time
In-Reply-To: <86eczkx4el.fsf@HIDDEN> (Eli Zaretskii's message of "Wed, 26 Feb
 2025 14:43:30 +0200")
References: <07eb92db-3c36-4db4-94e3-633b05f31f1b@HIDDEN>
 <86eczkx4el.fsf@HIDDEN>
Date: Mon, 14 Apr 2025 05:59:13 -0400
Message-ID: <yp1mscjt66m.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 76546
Cc: Christian Johansson <christian@HIDDEN>, 76546 <at> debbugs.gnu.org
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:

>> Date: Tue, 25 Feb 2025 11:27:58 +0100
>> From: Christian Johansson <christian@HIDDEN>
>> 
>> There is something fishy going on, but it is a very slippery bug, I have 
>> trouble reproducing it but it started to happen when native compilation 
>> was introduced and it has significantly gotten worse with Emacs 30, I 
>> never happened before native-compilation was introduced.
>> 
>> Maybe you can give me some tips in building a reproducible test case? I 
>> will try to explain what happens. So prior to Emacs 30 there was only 
>> one bug I stumbled upon:
>> 
>> 1. When a lambda is stored in a variable in a lexical scoped file it 
>> stores a closure. After some time when native compilation has done its 
>> magic on the variable you will get an error when you try to output it 
>> like this:
>> (format "%S" my-native-compiled-variable) and Emacs crashes.
>> 
>> This happened every time my parser-generator library ran for a long time 
>> and then tried to output a parser file. The only solution to this was to 
>> not byte-compile the file that contained the lambdas that was later 
>> supposed to be printed to a file, this solution worked but it was a 
>> workaround due to this bug.
>> 
>> 
>> 2. After Emacs 30 it seems to corrupt strings with escape sequences 
>> inside lambdas inside variables, like this:
>> 
>> (setq my-lambda (lambda() (looking-at "<\\?=")))
>> 
>> After native-compilation has performed its magic on the variable the 
>> function body will become corrupted and it will become a invalid 
>> function body. This happens now to my major my phps-mode, I have 
>> reproduced the error on two machines with Emacs 30 and it has never 
>> occurred before Emacs 30 and there has been no recent changes to the 
>> plugin. If I just eval the function files anew the problem disappears so 
>> it only happens in compiled files. It however does not happen in 
>> byte-compiled files, only in native compiled files.
>
> Andrea, any comments or suggestions?

I can't reproduce this on master.  I've:

test.el:
======
;; -*- lexical-binding: t -*-                                                        
(setq my-lambda (lambda() (looking-at "<\\?=")))
======

If I run emacs:
$ emacs --batch -eval '(progn (load (native-compile "/home/andcor03/test/test.el")) (funcall my-lambda))'

Seems to work for me.  Not sure if the reproducer should be something
different tho.

  Andrea




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#76546; Package emacs. Full text available.

Message received at 76546 <at> debbugs.gnu.org:


Received: (at 76546) by debbugs.gnu.org; 27 Feb 2025 08:03:50 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Feb 27 03:03:50 2025
Received: from localhost ([127.0.0.1]:57885 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tnYs1-0006kv-Jp
	for submit <at> debbugs.gnu.org; Thu, 27 Feb 2025 03:03:49 -0500
Received: from eggs.gnu.org ([2001:470:142:3::10]:40452)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <eliz@HIDDEN>) id 1tnYry-0006kf-No
 for 76546 <at> debbugs.gnu.org; Thu, 27 Feb 2025 03:03:47 -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 1tnYrr-00012F-Kx; Thu, 27 Feb 2025 03:03:39 -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=uiwPtzNF7+R951qnkmBlxX6fEbOsuNJVN7PY0gxxmww=; b=WEAw8f3ttap2
 pYrBgJtSRcv4RaOX3ry+lOxSP10xov+jHv0ZhjT7/lMwHy3OLVnGV8YSSzoQGpW/z9h4eyrYSotQW
 ZZYbqRw9q8FuQL5NCEHjyiE+RWv8FhPgomycoWy1jfXxb2yxqKvNkUPo2tFujmzQzjhDRdKR1WNjT
 a/tSMyjlGY1n1qJ+FcBNSwwCIUB2DEcCkPuiSeifRJUewtOBgY8cJOcwus7Q7VKfw5Cd94VexBIPr
 6k42m6feJm+oJcNZp4fW9SrghmLiRkA9noAMhtw6Iey8wyGN9RtrBXsnKpczE3BUMSiReUexPTnMR
 zObydmUbAiTakCfZTZWkTQ==;
Date: Thu, 27 Feb 2025 10:02:41 +0200
Message-Id: <864j0fvmqm.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Christian Johansson <christian@HIDDEN>
In-Reply-To: <DFC9C293-7520-44AE-B616-EF6D2B907579@HIDDEN> (message from
 Christian Johansson on Wed, 26 Feb 2025 21:55:28 +0100)
Subject: Re: bug#76546: 30.1;
 Native compilation is corrupting lambdas/closures stored in variables
 after some time
References: <86eczkx4el.fsf@HIDDEN>
 <DFC9C293-7520-44AE-B616-EF6D2B907579@HIDDEN>
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 76546
Cc: 76546 <at> debbugs.gnu.org, acorallo@HIDDEN
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 (---)

> From: Christian Johansson <christian@HIDDEN>
> Date: Wed, 26 Feb 2025 21:55:28 +0100
> Cc: Andrea Corallo <acorallo@HIDDEN>, 76546 <at> debbugs.gnu.org
> 
> Today the error disappeared on both machines without any changes in code, it makes no sense really but if I could trigger native compilation I could do some testing back and forth. It can be a issue with the garbage collection mechanism also, the things could be dependent on each other as well. Maybe only native compiled + byte compiled + garbage collected variables get corrupted sometimes?

If you need a way to trigger native compilation, then removing the
corresponding .eln file(s) should do it.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#76546; Package emacs. Full text available.

Message received at 76546 <at> debbugs.gnu.org:


Received: (at 76546) by debbugs.gnu.org; 26 Feb 2025 20:55:50 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Feb 26 15:55:50 2025
Received: from localhost ([127.0.0.1]:55696 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tnORa-0008KP-2R
	for submit <at> debbugs.gnu.org; Wed, 26 Feb 2025 15:55:50 -0500
Received: from mailrelay6-1.pub.mailoutpod3-cph3.one.com
 ([2a02:2350:5:425::1]:39823)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <christian@HIDDEN>) id 1tnORV-0008K8-B2
 for 76546 <at> debbugs.gnu.org; Wed, 26 Feb 2025 15:55:47 -0500
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1740603339;
 x=1741208139; d=cvj.se; s=rsa2;
 h=to:in-reply-to:cc:references:message-id:date:subject:mime-version:from:
 content-transfer-encoding:content-type:from;
 bh=HgiwMM1MO8lHaKdVnuS/OMJFxgxMw+Ac+N+72cmvvgU=;
 b=Wa4aCI34yh3k9EX0fzoDDinwxA2up/U718CKj+KOAGivPdZqGoGCiBHsKZyzppE1LztOL1lKhg7Rf
 vWczjogrWBOEuCVpR2SA1j/MC0MqtNlz3rIMGjdTsJqxXUA5FmiEHaq39uX0jymeFEJwzd+NLAcCr+
 tTn2Ye9XuXHs/473LC3Lu0NPnFBdbkf8KSzGwXe+mUlw77pntkgp53GQ37HOX7gM7JBLx7sPD56BPA
 1Wo69Eb2uaenCSei7qwswJqlCFfuG2+fwIRqGTeUR7FfV3M8MGA3Ud0BW96N7aIfZtqFopz7PdHB+N
 57sk8u+AjTGqanOn91Jot0ao3Opa0kA==
DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; t=1740603339;
 x=1741208139; d=cvj.se; s=ed2;
 h=to:in-reply-to:cc:references:message-id:date:subject:mime-version:from:
 content-transfer-encoding:content-type:from;
 bh=HgiwMM1MO8lHaKdVnuS/OMJFxgxMw+Ac+N+72cmvvgU=;
 b=5wTzICiwNsDuyTZQzlrFOAPxDJ0YnV1lasDSknVAK7sxUu44XYKg9QV+Mdpo3YTe1ler4xltEmaFv
 RDNegeeDQ==
X-HalOne-ID: 0854895d-f484-11ef-b680-417246ffdc90
Received: from smtpclient.apple (c-84-217-183-19.bbcust.telenor.se
 [84.217.183.19])
 by mailrelay6.pub.mailoutpod3-cph3.one.com (Halon) with ESMTPSA
 id 0854895d-f484-11ef-b680-417246ffdc90;
 Wed, 26 Feb 2025 20:55:38 +0000 (UTC)
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
From: Christian Johansson <christian@HIDDEN>
Mime-Version: 1.0 (1.0)
Subject: Re: bug#76546: 30.1;
 Native compilation is corrupting lambdas/closures stored in variables
 after some time
Date: Wed, 26 Feb 2025 21:55:28 +0100
Message-Id: <DFC9C293-7520-44AE-B616-EF6D2B907579@HIDDEN>
References: <86eczkx4el.fsf@HIDDEN>
In-Reply-To: <86eczkx4el.fsf@HIDDEN>
To: Eli Zaretskii <eliz@HIDDEN>
X-Mailer: iPhone Mail (22D72)
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 76546
Cc: 76546 <at> debbugs.gnu.org, Andrea Corallo <acorallo@HIDDEN>
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 (-)

Today the error disappeared on both machines without any changes in code, it=
 makes no sense really but if I could trigger native compilation I could do s=
ome testing back and forth. It can be a issue with the garbage collection me=
chanism also, the things could be dependent on each other as well. Maybe onl=
y native compiled + byte compiled + garbage collected variables get corrupte=
d sometimes?

Non reproducible bugs that only happen after a significant period of time.. v=
ariable data gets corrupted, that is at least true

Kind Regards
Christian

> On 26 Feb 2025, at 14:03, Eli Zaretskii <eliz@HIDDEN> wrote:
>=20
> =EF=BB=BF
>>=20
>> Date: Tue, 25 Feb 2025 11:27:58 +0100
>> From: Christian Johansson <christian@HIDDEN>
>>=20
>> There is something fishy going on, but it is a very slippery bug, I have
>> trouble reproducing it but it started to happen when native compilation
>> was introduced and it has significantly gotten worse with Emacs 30, I
>> never happened before native-compilation was introduced.
>>=20
>> Maybe you can give me some tips in building a reproducible test case? I
>> will try to explain what happens. So prior to Emacs 30 there was only
>> one bug I stumbled upon:
>>=20
>> 1. When a lambda is stored in a variable in a lexical scoped file it
>> stores a closure. After some time when native compilation has done its
>> magic on the variable you will get an error when you try to output it
>> like this:
>> (format "%S" my-native-compiled-variable) and Emacs crashes.
>>=20
>> This happened every time my parser-generator library ran for a long time
>> and then tried to output a parser file. The only solution to this was to
>> not byte-compile the file that contained the lambdas that was later
>> supposed to be printed to a file, this solution worked but it was a
>> workaround due to this bug.
>>=20
>>=20
>> 2. After Emacs 30 it seems to corrupt strings with escape sequences
>> inside lambdas inside variables, like this:
>>=20
>> (setq my-lambda (lambda() (looking-at "<\\?=3D")))
>>=20
>> After native-compilation has performed its magic on the variable the
>> function body will become corrupted and it will become a invalid
>> function body. This happens now to my major my phps-mode, I have
>> reproduced the error on two machines with Emacs 30 and it has never
>> occurred before Emacs 30 and there has been no recent changes to the
>> plugin. If I just eval the function files anew the problem disappears so
>> it only happens in compiled files. It however does not happen in
>> byte-compiled files, only in native compiled files.
>=20
> Andrea, any comments or suggestions?




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#76546; Package emacs. Full text available.

Message received at 76546 <at> debbugs.gnu.org:


Received: (at 76546) by debbugs.gnu.org; 26 Feb 2025 12:43:48 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Feb 26 07:43:48 2025
Received: from localhost ([127.0.0.1]:51388 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tnGlP-0007Kw-Dp
	for submit <at> debbugs.gnu.org; Wed, 26 Feb 2025 07:43:48 -0500
Received: from eggs.gnu.org ([2001:470:142:3::10]:35840)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <eliz@HIDDEN>) id 1tnGlI-0007Kb-SB
 for 76546 <at> debbugs.gnu.org; Wed, 26 Feb 2025 07:43:44 -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 1tnGlB-0003op-Hm; Wed, 26 Feb 2025 07:43:33 -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=Vph1IJ3BJ1rm/12D3wiUNqIWUZelNOdICzMp5lWBx68=; b=AIjfWgOw5nj+
 xCTk8FB3tVUfbASoUg0FzCbxoRRmtO1/4/vjafeZLRQLukIINLzvLYTL4DwhzD+AKy/KoXuoqhQ+Q
 ZT/kXkKZ2Cr508/tE6/8nslRsBfAXYax/CpHjZfAKe6VtNjxW/Ush2jkpxH3xG0BfdbGCXBXqeods
 qabsYZTSQJ8qVHCfNMqDy+OBCUu77WNV3q5lgeYGrk7dTegZHmLdG6TjAA7Se97wvnrcI4qlx9LXL
 ccxBW4yHAci+LOyX8/bCJ7kXbjPUAF3WwGgz0HIVGuBYH/6DZsKg9C7tlEU7J5Wv2N75rmsZHJ8n8
 wuaR/1A1dSTMvwE/NQDX9A==;
Date: Wed, 26 Feb 2025 14:43:30 +0200
Message-Id: <86eczkx4el.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Christian Johansson <christian@HIDDEN>, Andrea Corallo <acorallo@HIDDEN>
In-Reply-To: <07eb92db-3c36-4db4-94e3-633b05f31f1b@HIDDEN> (message from
 Christian Johansson on Tue, 25 Feb 2025 11:27:58 +0100)
Subject: Re: bug#76546: 30.1;
 Native compilation is corrupting lambdas/closures stored in variables
 after some time
References: <07eb92db-3c36-4db4-94e3-633b05f31f1b@HIDDEN>
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 76546
Cc: 76546 <at> debbugs.gnu.org
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 (---)

> Date: Tue, 25 Feb 2025 11:27:58 +0100
> From: Christian Johansson <christian@HIDDEN>
> 
> There is something fishy going on, but it is a very slippery bug, I have 
> trouble reproducing it but it started to happen when native compilation 
> was introduced and it has significantly gotten worse with Emacs 30, I 
> never happened before native-compilation was introduced.
> 
> Maybe you can give me some tips in building a reproducible test case? I 
> will try to explain what happens. So prior to Emacs 30 there was only 
> one bug I stumbled upon:
> 
> 1. When a lambda is stored in a variable in a lexical scoped file it 
> stores a closure. After some time when native compilation has done its 
> magic on the variable you will get an error when you try to output it 
> like this:
> (format "%S" my-native-compiled-variable) and Emacs crashes.
> 
> This happened every time my parser-generator library ran for a long time 
> and then tried to output a parser file. The only solution to this was to 
> not byte-compile the file that contained the lambdas that was later 
> supposed to be printed to a file, this solution worked but it was a 
> workaround due to this bug.
> 
> 
> 2. After Emacs 30 it seems to corrupt strings with escape sequences 
> inside lambdas inside variables, like this:
> 
> (setq my-lambda (lambda() (looking-at "<\\?=")))
> 
> After native-compilation has performed its magic on the variable the 
> function body will become corrupted and it will become a invalid 
> function body. This happens now to my major my phps-mode, I have 
> reproduced the error on two machines with Emacs 30 and it has never 
> occurred before Emacs 30 and there has been no recent changes to the 
> plugin. If I just eval the function files anew the problem disappears so 
> it only happens in compiled files. It however does not happen in 
> byte-compiled files, only in native compiled files.

Andrea, any comments or suggestions?




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#76546; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 25 Feb 2025 10:29:25 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Feb 25 05:29:24 2025
Received: from localhost ([127.0.0.1]:44941 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tmsBo-0000No-Ew
	for submit <at> debbugs.gnu.org; Tue, 25 Feb 2025 05:29:24 -0500
Received: from lists.gnu.org ([2001:470:142::17]:58212)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <christian@HIDDEN>) id 1tmsBl-0000NO-W5
 for submit <at> debbugs.gnu.org; Tue, 25 Feb 2025 05:29:22 -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 <christian@HIDDEN>) id 1tmsBf-0000sm-Pe
 for bug-gnu-emacs@HIDDEN; Tue, 25 Feb 2025 05:29:15 -0500
Received: from mailrelay6-1.pub.mailoutpod2-cph3.one.com ([46.30.211.181])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <christian@HIDDEN>) id 1tmsBc-0002da-WD
 for bug-gnu-emacs@HIDDEN; Tue, 25 Feb 2025 05:29:15 -0500
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1740479278;
 x=1741084078; d=cvj.se; s=rsa2;
 h=content-transfer-encoding:content-type:subject:from:to:mime-version:date:
 message-id:from;
 bh=rWRmPA3x/3bijhtMvGC+n0EAOg8aaIojXtrPxSpjqTs=;
 b=N0zWqpMlAca047kmbcoN5tzVPSS9cjwmtCLVMMId3XTy0ioSrB7/O0ddTahkbbIUXXoAf2wVem4ll
 R3FzF3rneHEAduYFgIPmNmxnAtJ7g0JgSgLblmn+u62UpBMavo0XDCsRpF02qPMuRdJukE8S9Gfq8X
 m/WrDteNKaHRr1MisR7e4CRwudaARe+8ZfKP6llMcdHgZgZBSELVtDO2I/QytzTBKKsSWEI6zZyOLH
 hjQCgmQdQYbeaUgC7iiO2KuK4iKB5tK+TLQEtxho+OOkjjX0rYGstAmXx6nuFkblsqXa+qFd0bZWsT
 LLt87e3domxZywXYPoc/f1yBvROzokw==
DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; t=1740479278;
 x=1741084078; d=cvj.se; s=ed2;
 h=content-transfer-encoding:content-type:subject:from:to:mime-version:date:
 message-id:from;
 bh=rWRmPA3x/3bijhtMvGC+n0EAOg8aaIojXtrPxSpjqTs=;
 b=BRvYXK2+YomgHTtWrIOTCKlAcp8LBh303SHgKpg0haAZVGTXnkfry8Qtv+lh1q7dbEVZU9v+1GixH
 C9pMAQcBQ==
X-HalOne-ID: 2e97cd77-f363-11ef-9766-15d104443858
Received: from [192.168.50.197] (c-84-217-183-19.bbcust.telenor.se
 [84.217.183.19])
 by mailrelay6.pub.mailoutpod2-cph3.one.com (Halon) with ESMTPSA
 id 2e97cd77-f363-11ef-9766-15d104443858;
 Tue, 25 Feb 2025 10:27:58 +0000 (UTC)
Message-ID: <07eb92db-3c36-4db4-94e3-633b05f31f1b@HIDDEN>
Date: Tue, 25 Feb 2025 11:27:58 +0100
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
Content-Language: en-US
To: bug-gnu-emacs@HIDDEN
From: Christian Johansson <christian@HIDDEN>
Subject: 30.1; Native compilation is corrupting lambdas/closures stored in
 variables after some time
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Received-SPF: none client-ip=46.30.211.181; envelope-from=christian@HIDDEN;
 helo=mailrelay6-1.pub.mailoutpod2-cph3.one.com
X-Spam_score_int: -20
X-Spam_score: -2.1
X-Spam_bar: --
X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
 DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
 RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001,
 RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001,
 SPF_HELO_PASS=-0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: submit
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 (-)

Hello!

There is something fishy going on, but it is a very slippery bug, I have 
trouble reproducing it but it started to happen when native compilation 
was introduced and it has significantly gotten worse with Emacs 30, I 
never happened before native-compilation was introduced.

Maybe you can give me some tips in building a reproducible test case? I 
will try to explain what happens. So prior to Emacs 30 there was only 
one bug I stumbled upon:

1. When a lambda is stored in a variable in a lexical scoped file it 
stores a closure. After some time when native compilation has done its 
magic on the variable you will get an error when you try to output it 
like this:
(format "%S" my-native-compiled-variable) and Emacs crashes.

This happened every time my parser-generator library ran for a long time 
and then tried to output a parser file. The only solution to this was to 
not byte-compile the file that contained the lambdas that was later 
supposed to be printed to a file, this solution worked but it was a 
workaround due to this bug.


2. After Emacs 30 it seems to corrupt strings with escape sequences 
inside lambdas inside variables, like this:

(setq my-lambda (lambda() (looking-at "<\\?=")))

After native-compilation has performed its magic on the variable the 
function body will become corrupted and it will become a invalid 
function body. This happens now to my major my phps-mode, I have 
reproduced the error on two machines with Emacs 30 and it has never 
occurred before Emacs 30 and there has been no recent changes to the 
plugin. If I just eval the function files anew the problem disappears so 
it only happens in compiled files. It however does not happen in 
byte-compiled files, only in native compiled files.


Kind regards
Christian







Acknowledgement sent to Christian Johansson <christian@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to bug-gnu-emacs@HIDDEN:
bug#76546; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Sat, 26 Apr 2025 13:15:02 UTC

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