Bug 69945 - Provide an equivalent of __libc_freeres to release emergency EH pool memory
Summary: Provide an equivalent of __libc_freeres to release emergency EH pool memory
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: libstdc++ (show other bugs)
Version: 5.3.0
: P3 normal
Target Milestone: 6.0
Assignee: Not yet assigned to anyone
URL: https://bugs.kde.org/show_bug.cgi?id=...
Keywords:
Depends on:
Blocks:
 
Reported: 2016-02-24 17:16 UTC by Jonathan Wakely
Modified: 2021-11-19 15:46 UTC (History)
5 users (show)

See Also:
Host:
Target:
Build:
Known to work: 6.0
Known to fail:
Last reconfirmed: 2016-04-26 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jonathan Wakely 2016-02-24 17:16:23 UTC
Glibc provides a hook that tools such as valgrind and sanitizers can call to release "still reachable" memory that is in use at program exit.

We should do the same, so that the emergency EH pool can be freed, and people will stop reporting "still reachable" memory as a leak in libstdc++.

It won't be possible to backport a new global symbol to gcc-5-branch unless we do it before the gcc 6 release, using libstdc++.so.6.0.22 for gcc 5.4, and then using libstdc++.so.6.0.23 for gcc 6.

To avoid exporting a new global symbol in gcc-5-branch it could be put in a special section, which would allow valgrind to find it without going through the symbol table. (We'd probably still want a global symbol for future releases, so that other tools can call it the obvious way).
Comment 1 Mark Wielaard 2016-02-24 22:44:58 UTC
See also this valgrind bug: https://bugs.kde.org/show_bug.cgi?id=345307
Comment 2 Richard Biener 2016-02-25 08:41:28 UTC
but as the allocator lives in libsupc++ which is static only we can add that symbol there (unversioned)?
Comment 3 Jakub Jelinek 2016-02-25 08:43:01 UTC
libsupc++ is linked into libstdc++.so.6.
Comment 4 rguenther@suse.de 2016-02-25 09:28:58 UTC
On Thu, 25 Feb 2016, jakub at gcc dot gnu.org wrote:

> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69945
> 
> --- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
> libsupc++ is linked into libstdc++.so.6.

But the hook could be unversioned?  AFAIK it is going to be used
via dlsym only?
Comment 5 Jakub Jelinek 2016-02-25 09:55:06 UTC
Unversioned symbols in otherwise versioned shared library?  On some systems impossible, on others possible through ugly hacks.  IMHO we don't want that.
Comment 6 Jonathan Wakely 2016-03-24 18:14:12 UTC
Author: redi
Date: Thu Mar 24 18:13:40 2016
New Revision: 234465

URL: https://gcc.gnu.org/viewcvs?rev=234465&root=gcc&view=rev
Log:
libstdc++/69945 Add __gnu_cxx::__freeres hook

	PR libstdc++/69945
	* config/abi/pre/gnu.ver: Add new symbol.
	* libsupc++/eh_alloc.cc (__gnu_cxx::__freeres): Define.
	* testsuite/18_support/free_eh_pool.cc: New test.

Added:
    trunk/libstdc++-v3/testsuite/18_support/free_eh_pool.cc
Modified:
    trunk/libstdc++-v3/ChangeLog
    trunk/libstdc++-v3/config/abi/pre/gnu.ver
    trunk/libstdc++-v3/libsupc++/eh_alloc.cc
Comment 7 Jonathan Wakely 2017-05-17 18:14:03 UTC
Implemented for GCC 6, I'm not hearing demand to backport to GCC 5.

Please reopen the bug if it's needed and we can make it work without exporting the new symbol.