[PATCH 1/3] stdio: Clean up __libc_message after unconditional abort
Adhemerval Zanella Netto
adhemerval.zanella@linaro.org
Tue Aug 2 13:43:46 GMT 2022
On 02/08/22 05:03, Florian Weimer wrote:
> * 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.
My intention was more to move away from old atomics macros and use compiler
builtins when possible.
More information about the Libc-alpha
mailing list