diff options
author | Carlos O'Donell <carlos@systemhalted.org> | 2017-09-28 11:05:18 -0600 |
---|---|---|
committer | Carlos O'Donell <carlos@systemhalted.org> | 2017-10-06 09:31:52 -0700 |
commit | 1e26d35193efbb29239c710a4c46a64708643320 (patch) | |
tree | 711bdaefe5af9f9566c3a9e101b7328f565faa61 /ChangeLog | |
parent | d13867625894fda6c6a5034dadfa8ff86983ea12 (diff) | |
download | glibc-1e26d35193efbb29239c710a4c46a64708643320.tar glibc-1e26d35193efbb29239c710a4c46a64708643320.tar.gz glibc-1e26d35193efbb29239c710a4c46a64708643320.tar.bz2 glibc-1e26d35193efbb29239c710a4c46a64708643320.zip |
malloc: Fix tcache leak after thread destruction [BZ #22111]
The malloc tcache added in 2.26 will leak all of the elements remaining
in the cache and the cache structure itself when a thread exits. The
defect is that we do not set tcache_shutting_down early enough, and the
thread simply recreates the tcache and places the elements back onto a
new tcache which is subsequently lost as the thread exits (unfreed
memory). The fix is relatively simple, move the setting of
tcache_shutting_down earlier in tcache_thread_freeres. We add a test
case which uses mallinfo and some heuristics to look for unaccounted for
memory usage between the start and end of a thread start/join loop. It
is very reliable at detecting that there is a leak given the number of
iterations. Without the fix the test will consume 122MiB of leaked
memory.
Diffstat (limited to 'ChangeLog')
-rw-r--r-- | ChangeLog | 9 |
1 files changed, 9 insertions, 0 deletions
@@ -1,3 +1,12 @@ +2017-10-06 Carlos O'Donell <carlos@redhat.com> + + [BZ #22111] + * malloc/malloc.c (tcache_shutting_down): Use bool type. + (tcache_thread_freeres): Set tcache_shutting_down before + freeing the tcache. + * malloc/Makefile (tests): Add tst-malloc-tcache-leak. + * malloc/tst-malloc-tcache-leak.c: New file. + 2017-10-06 Rajalakshmi Srinivasaraghavan <raji@linux.vnet.ibm.com> * sysdeps/powerpc/powerpc64/multiarch/memrchr-ppc64.c: Revert |