GNU bug report logs - #75845
mapconcat crashes for unreasonable self-modifications

Previous Next

Package: emacs;

Reported by: Pip Cet <pipcet <at> protonmail.com>

Date: Sun, 26 Jan 2025 02:03:02 UTC

Severity: normal

Full log


Message #44 received at 75845 <at> debbugs.gnu.org (full text, mbox):

From: Mattias EngdegÄrd <mattias.engdegard <at> gmail.com>
To: Pip Cet <pipcet <at> protonmail.com>
Cc: Eli Zaretskii <eliz <at> gnu.org>, monnier <at> iro.umontreal.ca,
 75845 <at> debbugs.gnu.org
Subject: Re: bug#75845: mapconcat crashes for unreasonable self-modifications
Date: Fri, 21 Feb 2025 16:10:45 +0100
21 feb. 2025 kl. 13.35 skrev Pip Cet <pipcet <at> protonmail.com>:

> (If we really want to optimize it further, let's get rid of the strange
> double loop in mapconcat first, which spreads the arguments then goes
> back over the list in reverse order to fill in the separators).

I don't think it's really a cache killer but will give it a look.

> I maintain that using strings as a sequence argument to the map*
> functions is so rare we should just turn them into a list or vector
> instead and drop the special-casing code.

I'll think about it.

> I'm still not convinced abolishing string mutation is a good idea,

Let's try to solve this bug in isolation. We're almost done!

> With maphash, this actually happens (it does, or did, in the nativecomp
> code) by accident.  I'm not sure the same is true for sequences, where
> "don't crash" is probably the best we can hope for.

Lisp shouldn't crash but it's impractical to be absolute about it. The programming interface is so rich that it's almost impossible to prevent crashes altogether, and performance considerations further reduce what checks we want to perform. For instance, the user can easily crash Emacs by running bad bytecode. But users expect more about basic Lisp primitives like mapcar & co and since it seems that a reasonable effort can prevent it, and it's not (too) expensive, let's try.

Feel free to commit your patch, or post it here if you want us to poke fun at it beforehand.





This bug report was last modified 210 days ago.

Previous Next


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