Subject: bug#76091: 31.0.50; festure/igc: buffer.h:829: Emacs fatal error: assertion failed: BUFFERP (a)

From: Gerd Möllmann <[email-masked]>
Date: Fri, 7 Feb 2025 17:16:07 +0100

On 7. Feb 2025, at 17:07, Pip Cet <[email-masked]> wrote:
> 
> Gerd Möllmann <[email-masked]> writes:
> 
>> Pip Cet <[email-masked]> writes:
>> 
>>> Well, here it is:
>> 
>> IIUC, that fixes the problem with igc_on_grow_specpdl as part of a
>> grander effort that avoids parking the arena in more cases.
> 
> My assumption was the other root resizing methods would have similar
> issues, yes.  I'm not sure this is true, but why risk it?

Yes, true. 

> 
>> (I'd naively just written a new igc_xpalloc_specpdl patterned after the
>> existing igc_xpalloc_exectly and ambig variants, but I'm also lazy :-).)
> 
> Laziness is a virtue for hackers :-)
> 
>> Hard to review. Did you take this into account?
> 
> Well, yes.  I'll split it up into individual patches, so we can review
> them one by one?

Not necessary, but thanks. 

> 
>> igc.c:
>> 3240   /* Can't make a root that has zero length.  Want one to be able to
>> 3241      detect calling igc_free on something not having a root.  */
>> 3242   void *end = (char *) p + size;
>> 3243   if (end == p)
>> 3244     end = (char *) p + IGC_ALIGN_DFLT;
>> 3245   root_create_ambig (global_igc, p, end, "xzalloc-ambig");
> 
> Ugh.  No, I didn't.  Need to fix igc_realloc_ambig (also, it doesn't
> handle the "shrinking" case correctly, oops.  However, there appear to
> be no callers of igc_realloc_ambig that expect the root to shrink,
> whew).
> 
> As for that code, is it really necessary to lie about this case?  Can't
> we simply force size to be >= IGC_ALIGN_DFLT when making the allocation?
> 

We could do that. I did it only that way because it was easy and unproblematic at that time.