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

From: Gerd Möllmann <[email-masked]>
Date: Fri, 03 Jan 2025 20:55:02 +0100

Pip Cet <[email-masked]> writes:

> process.c and callproc.c use ALLOCA to store arrays of Lisp_Object
> values, or arrays of pointers to string data.
>
> With the current GC, that is correct code only if it's provable that
> these objects are marked through some other reference to them (or we
> know no GC can happen), because if the last reference is hiding in a
> SAFE_ALLOCA'd buffer AND that buffer is not on the C stack, it will be
> collected.
>
> With MPS GC, it's even more important to do so, because the object might
> otherwise be moved, invalidating the pointer.  This is a possible
> explanation for bug#75292.
>
> In either case, I don't immediately see that the current code would be
> safe.

I agree.

One should probably check why the places storing Lisp_Objects don't use
SAFE_ALLOCA_LISP. If that's possible it would work for old GC and igc.

The pointers to string data case probably requires adding yet another
macro SAFE_ALLOCA_FIND_A_GOOD_NAME, which, for MPS, allocates a root,
possibly and exact one which would be good.