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

From: Gregory Heytings <[email-masked]>
Date: Fri, 10 Mar 2023 09:40:31 +0000

>>> AFAICT, they _are_ frozen.  These names are in read-only memory, where 
>>> you cannot write.  That's why Emacs crashes, AFAIU: the code is trying 
>>> to write to protected memory.
>>>
>>> Just don't do that, cause it's gonna hurt...
>>
>> Is it not possible to detect this before the illegal memory access, and 
>> raise a signal in Emacs Lisp?
>
> It won't be easy, if at all possible.  And I'm not sure we even want to 
> do that.  What would be the purpose of supporting such a use of Emacs?
>

Instead of raising a signal, I suggest:

diff --git a/src/data.c b/src/data.c
index 0f1d881e00b..76867d6787e 100644
--- a/src/data.c
+++ b/src/data.c
@@ -780,7 +780,7 @@ DEFUN ("symbol-name", Fsymbol_name, Ssymbol_name, 1, 
1, 0,

    CHECK_SYMBOL (symbol);
    name = SYMBOL_NAME (symbol);
-  return name;
+  return build_string (SSDATA (name));
  }

  DEFUN ("bare-symbol", Fbare_symbol, Sbare_symbol, 1, 1, 0,