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

From: Gerd Möllmann <[email-masked]>
Date: Sun, 05 Jan 2025 09:19:17 +0100

Eli Zaretskii <[email-masked]> writes:

>> Cc: [email-masked]
>> From: Gerd Möllmann <[email-masked]>
>> Date: Sun, 05 Jan 2025 07:32:46 +0100
>> 
>> Just want to add that all SAFE_NALLOC uses should be checked in
>> scratch/igc. For example, set_overlays_multibyte uses it to store
>> itree_node *, and itree_node is in MPS.
>
> Can you tell more about what should be checked and how?  I'm probably
> missing some details of the igc build, because I cannot translate what
> you say above into practical actions of auditing the code.
>
> Thanks.

I'd grep for SAFE_NALLOCA, and for each occurrence, see what is stored
in the memory allocated. If that is a reference to MPS-allocated memory
(a pointer or Lisp_Object), it should be changed, because it then hides
references from MPS in malloc'd memory. Or can hide, to be more precise,
in the case it doesn't use alloca.

Or alternatively, you could avoid having to do that, and make
SAFE_NALLOCA xmalloc an ambiguous root. A patch for that is in the other
mail I sent. I think the performance impact of that is negligible
because this path is only executed when SAFE_ALLOCA does not use alloca.