[PATCH] assert: Remove the use of %n from __assert_fail_base (BZ #32456)

Adhemerval Zanella Netto adhemerval.zanella@linaro.org
Mon Dec 30 20:04:33 GMT 2024



On 30/12/24 17:00, Florian Weimer wrote:
> * Adhemerval Zanella Netto:
> 
>> The patch that added mmap (f8a3b5bf8fa1d0c43d2458e03cc109a04fdef194) was
>> not clear about the rationale, but my wild guess would be to have a 
>> direct way to get the abort message in a post-mortem analysis (instead
>> to try dig it from malloc metadata).
> 
> Sure, but if we are using malloc anyway, we could just allocate it using
> malloc and write it to some global pointer?

Ah right, you mean the double allocation (asnprint and then mmap). It is
not clear to me why it is required as well.

> 
> And perhaps we should just stop copying the message after the first
> assertion failure.  I mean, if an application continues to run after an
> assertion failure with some SIGABRT handler, some degraded debugging
> functionality seems perfectly fine to me.

Sounds reasonable.

> 
> Anyway, separate matter, unrelated to this patch.
> 
>> But it is not really clear to me the why we need to keep the __abort_msg,
>> and if this is really useful.  Also, the assert implementation now requires
>> multiple allocation (the translation, the asprintf, and the mmap), which
>> adds a lot of overhead and multiple point of failures that makes the interface
>> moot (although mot likely memory allocation won't fail).  
> 
> The issue is that the assert expression and file name won't end up in a
> core file if we don't make a copy.  Copying it makes sense, but a
> (possibly truncated) on-stack copy seems perfectly sufficient to me.

It would require a quite large stack (to accommodate PATH_MAX), so
I am not sure it would be a improvement over mmap. 


More information about the Libc-alpha mailing list