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

Florian Weimer fweimer@redhat.com
Mon Dec 30 20:00:12 GMT 2024


* 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?

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.

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.

Thanks,
Florian



More information about the Libc-alpha mailing list