[PATCH] Add comments to explain when a stream is freed by, __libc_freeres().

Carlos O'Donell carlos@redhat.com
Thu Jun 4 18:35:54 GMT 2020

On 5/26/20 3:53 AM, Florian Weimer wrote:
> We should only deallocate stdin/stdout/stderr in this way.  If there are
> more streams around, the user neglected to call fclose on them, so there
> is already a leak, and the reporting does not improve if we deallocate
> their buffers.

Agreed, and I think this is the right strategy here.
> I believe buffer deallocation can be handled in a conservative way, so
> that the buffer gets reallocated again if needed later during shutdown.


> It should free an automatically allocated buffer for stdin/stdout/stderr
> (all the internal handles, in various versions).  Full deallocation
> seems impossible and undesirable.


I think that sets consensus for this. I'm not sure I want to prioritize
fixing this right now, but I'll look at the code for a bit more and see
if it's fixable without too much problem.


More information about the Libc-alpha mailing list