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

Previous Next

Package: emacs;

Reported by: Christian Johansson <christian <at> cvj.se>

Date: Tue, 25 Feb 2025 10:30:02 UTC

Severity: normal

Found in version 30.1

Done: Stefan Monnier <monnier <at> iro.umontreal.ca>

Full log


View this message in rfc822 format

From: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: Christian Johansson <christian <at> cvj.se>
Subject: bug#76546: closed (Re: bug#76546: 30.1; Native compilation is
 corrupting lambdas/closures stored in variables after some time)
Date: Tue, 20 May 2025 17:28:02 +0000
[Message part 1 (text/plain, inline)]
Your bug report

#76546: 30.1; Native compilation is corrupting lambdas/closures stored in variables after some time

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to 76546 <at> debbugs.gnu.org.

-- 
76546: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=76546
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: Christian Johansson <christian <at> cvj.se>, acorallo <at> gnu.org,
 76546-done <at> debbugs.gnu.org
Subject: Re: bug#76546: 30.1; Native compilation is corrupting
 lambdas/closures stored in variables after some time
Date: Tue, 20 May 2025 13:26:48 -0400
>> I have a discussion with Stefan Monnier about this, this seems to be a
>> feature and not a bug, the printing of lambdas has been limited in new
>> Emacs version to avoid this issue I think
> Was the discussion with Stefan off-list?

My best guess is that he's referring to

    https://lists.gnu.org/archive/html/emacs-devel/2025-05/msg00133.html

> Stefan, should I close this bug, then?

I think so, mostly because there is no actionable element in it: no
clear description of what was the problem and even less info about how
to reproduce it.


        Stefan


[Message part 3 (message/rfc822, inline)]
From: Christian Johansson <christian <at> cvj.se>
To: bug-gnu-emacs <at> gnu.org
Subject: 30.1; Native compilation is corrupting lambdas/closures stored in
 variables after some time
Date: Tue, 25 Feb 2025 11:27:58 +0100
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






This bug report was last modified 26 days ago.

Previous Next


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