[PATCH 1/3] stdio: Clean up __libc_message after unconditional abort
Florian Weimer
fweimer@redhat.com
Tue Aug 2 08:03:49 GMT 2022
* Adhemerval Zanella Netto via Libc-alpha:
>> + buf->size = total;
>> + char *wp = buf->msg;
>> + for (int cnt = 0; cnt < nlist; ++cnt)
>> + wp = mempcpy (wp, iov[cnt].iov_base, iov[cnt].iov_len);
>> + *wp = '\0';
>> +
>> + /* We have to free the old buffer since the application might
>> + catch the SIGABRT signal. */
>> + struct abort_msg_s *old = atomic_exchange_acq (&__abort_msg,
>> + buf);
>> + if (old != NULL)
>> + __munmap (old, old->size);
>
> I am aware that this is just replicating the code already in place, but maybe
> replace the old atomic with atomic_exchange_acquire here.
We should use a CAS here anyway because the earlier message is likely
more valuable for debugging purposes. The exchange was needed because
when __libc_message could continue execution in the old days, we had to
somehow avoid the memory leak. That's no longer a concern with the
current code. I will try to clean this up further.
Thanks,
Florian
More information about the Libc-alpha
mailing list