Subject: Re: bug#79425: 31.0.50; `subst-char-in-string' crashes

From: Eli Zaretskii <[email-masked]>
Date: Thu, 11 Sep 2025 07:48:09 +0300

tags 79425 notabug
thanks

> Cc: [email-masked]
> Date: Wed, 10 Sep 2025 23:51:52 +0200
> From:  Stephen Berman via "Bug reports for GNU Emacs,
>  the Swiss army knife of text editors" <[email-masked]>
> 
> On Wed, 10 Sep 2025 23:24:13 +0200 Rudolf Adamkovič <[email-masked]> wrote:
> 
> > I am trying to export an Org mode file with citations using Emacs
> > compiled from `master' on NS.  The export crashes in `citeproc-el', a
> > 3rd-party library used by Org to format citations.  I reported the
> > problem upstream [1], and it seems to be a problem with Emacs itself.
> >
> > [1] https://github.com/andras-simonyi/citeproc-el/issues/181
> >
> > REPRODUCTION STEPS:
> >
> >   1. Checkout Emacs from Git commit `66ef930ebea'.
> >   1. Run `emacs -Q' on NS (MacOS 15.5).
> >   2. Evaluate `(subst-char-in-string 39 700 "D'Arcus" t)' in *scratch*.
> >
> > UNEXPECTED ERROR:
> >
> >   Debugger entered--Lisp error: (error "Attempt to store non-byte value into unibyte string")
> >     aset("D'Arcus" 1 700)
> 
> This is due to this change:
> 
> commit 308e3ab1dbd9633b843541af55d77c82b725df02
> Author:     Mattias Engdegård <[email-masked]>
> Commit:     Mattias Engdegård <[email-masked]>
> CommitDate: Sun Aug 24 10:28:27 2025 +0200
> 
>     Disallow string data resizing (bug#79784)
>     
>     Only allow string mutation that is certain not to require string data to
>     be resized and reallocated: writing bytes into a unibyte string, and
>     changing ASCII to ASCII in a multibyte string.
>     
>     This ensures that mutation will never transform a unibyte string to
>     multibyte, that the size of a string in bytes never changes, and that
>     the byte offsets of characters remain the same.  Most importantly, it
>     removes a long-standing obstacle to reform of string representation and
>     allow for future performance improvements.
>     
>     * src/data.c (Faset): Disallow resizing string mutation.
>     [...]

Indeed, and so this is not a bug, but a deliberate change, documented
in NEWS.

(It is also wrong to say "crashes" when actually Emacs signals an
error.)