Bug or not? printf allocates buffer & never frees it
Florian Weimer
fweimer@redhat.com
Wed Mar 17 21:03:57 GMT 2021
* Godmar Back:
> Is GNU libc designed to be used in environments that do not deallocate
> all memory upon exit(), i.e., environments that can call exit()
> multiple times without being provided with a fresh heap each time? I
> understand ISO C allows this and POSIX is quiet on this specific
> issue. Is complete deallocation of one-time buffers before exit() a
> design goal of GNU libc?
Not really. None of the currently supported targets behave in that way.
We have __libc_freeres to clean up *after* exit (and atexit handlers
etc.), but it only exists for leak debuggers. valgrind can call it, for
example, and we also call it in mtrace mode. It's also a bit of a
reasonable effort thing: there are allocations we currently do not free,
particularly around dlopen.
Thanks,
Florian
More information about the Libc-help
mailing list