Subject: bug#75322: SAFE_ALLOCA assumed to root Lisp_Objects/SSDATA(string)

From: Eli Zaretskii <[email-masked]>
Date: Mon, 06 Jan 2025 15:26:15 +0200

> From: Daniel Colascione <[email-masked]>
> Cc: [email-masked],  [email-masked],  [email-masked]
> Date: Sun, 05 Jan 2025 18:28:59 -0500
> 
> Daniel Colascione <[email-masked]> writes:
> 
> Here's a demonstration of the problem.  Run ./emacs -batch -Q --eval
> '(acos 0)'.  If you leave demo_crash to true, Emacs will abort quickly
> after we detect a use-after-free.  If you set demo_crash to false, Emacs
> will run the loop all day.

It is a well-known fact that inserting Fgarbage_collect in various
random places can cause bugs.  But expecting every Emacs C-level
hacker to write code that will endure such testing is impractical.  We
routinely let much more easily-spotted blunders slip though.  The
sheer number of subtleties and factoids you need to keep in mind when
writing safe code in Emacs is already inhumanly large.

We only get away because there are many places where GC cannot happen.
Admittedly, with the proliferation of calls into Lisp, there's less
and less of these places each year.