[patch] libstdc++/69945 Add __gnu_cxx::__freeres hook
Jonathan Wakely
jwakely@redhat.com
Wed Feb 24 18:36:00 GMT 2016
This adds a new function to libsupc++ which will free the memory still
in use by the pool used for allocating exceptions when malloc fails.
This is similar to glibc's __libc_freeres, which valgrind (and other
tools?) use to tell glibc to deallocate everything before exiting.
I initially called it __gnu_cxx::__free_eh_pool() but I figured we
might have other memory in use at some later date, and we wouldn't
want valgrind to have to start calling a second function, nor make a
function called __free_eh_pool() actually free other things.
I intentionally *didn't* lock the pool's mutex before freeing it,
because this should never be called in a context where multiple
threads are still active and accessing the pool.
Thoughts?
Is the new test a good idea, or will exposing it like that in the
testsuite just give users the idea that they can/should be doing the
same themselves?
[ Aside: should the actual pool be created with placement-new to
[ ensure it doesn't ever get destroyed?
[
[ alignas(pool) unsigned char poolbuf[sizeof(pool)];
[ pool& emergency_pool = *::new(poolbuf) pool;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch.txt
Type: text/x-patch
Size: 2845 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/libstdc++/attachments/20160224/ce82b354/attachment.bin>
More information about the Libstdc++
mailing list