Subject: Re: bug#62009: 29.0.60; Emacs crashes on setf symbol-name

From: Daniel Mendler <[email-masked]>
Date: Fri, 10 Mar 2023 12:36:17 +0100

On 3/10/23 12:30, Robert Pluim wrote:
>>>>>> On Fri, 10 Mar 2023 12:09:59 +0100, Daniel Mendler <[email-masked]> said:
> 
>     Daniel> One could check if the string is located in read-only memory. Or one
>     Daniel> could add a flag bit to the string data structure (and possibly to other
>     Daniel> data structures too). Freezing data structures such that they become
>     Daniel> read-only is a generally useful feature. There won't be any performance
>     Daniel> overhead of the check since a branch not taken is fast thanks to the
>     Daniel> branch predictor.
> 
> We already have such a flag:
> 
>       /* Number of characters in string; MSB is used as the mark bit.  */
>       ptrdiff_t size;
>       /* If nonnegative, number of bytes in the string (which is multibyte).
> 	 If negative, the string is unibyte:
> 	 -1 for data normally allocated
> 	 -2 for data in rodata (C string constants)
> 	 -3 for data that must be immovable (used for bytecode)  */
>       ptrdiff_t size_byte;

Thanks! That's good. Given that a read only flag already exists, it is
easy to fix the issue. We just have to make sure that the size is
negative for the symbol names and add a check in `aset`.

Daniel