GNU bug report logs - #62009
29.0.60; Emacs crashes on setf symbol-name

Previous Next

Package: emacs;

Reported by: Daniel Mendler <mail <at> daniel-mendler.de>

Date: Mon, 6 Mar 2023 19:28:01 UTC

Severity: normal

Found in version 29.0.60

Full log


View this message in rfc822 format

From: Po Lu <luangruo <at> yahoo.com>
To: Robert Pluim <rpluim <at> gmail.com>
Cc: Philip Kaludercic <philipk <at> posteo.net>, michael_heerdegen <at> web.de, Daniel Mendler <mail <at> daniel-mendler.de>, Gregory Heytings <gregory <at> heytings.org>, monnier <at> iro.umontreal.ca, 62009 <at> debbugs.gnu.org, Eli Zaretskii <eliz <at> gnu.org>, Augusto Stoffel <arstoffel <at> gmail.com>
Subject: bug#62009: 29.0.60; Emacs crashes on setf symbol-name
Date: Sat, 11 Mar 2023 15:07:56 +0800
Robert Pluim <rpluim <at> gmail.com> writes:

>>>>>> On Fri, 10 Mar 2023 12:09:59 +0100, Daniel Mendler <mail <at> daniel-mendler.de> 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;
>
> Try this:
>
> diff --git a/src/lisp.h b/src/lisp.h
> index 1276285e2f2..80bbb047824 100644
> --- a/src/lisp.h
> +++ b/src/lisp.h
> @@ -1685,6 +1685,8 @@ SREF (Lisp_Object string, ptrdiff_t index)
>  INLINE void
>  SSET (Lisp_Object string, ptrdiff_t index, unsigned char new)
>  {
> +  if (XSTRING (string)->u.s.size_byte == -2)
> +    Fsignal (Qsetting_constant, string);
>    SDATA (string)[index] = new;
>  }
>  INLINE ptrdiff_t
>
> Robert

Why does this have to be in SSET and not in PURE_P?




This bug report was last modified 2 years and 89 days ago.

Previous Next


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