Memory Leak in Thread Cleanup (jemalloc 4.0.4)
Jason Evans
jasone at canonware.com
Sat Feb 27 21:33:13 PST 2016
On Feb 11, 2016, at 2:33 PM, Christopher Ferris <cferris at google.com> wrote:
> It appears, that under certain circumstances, the arenas_cache can be leaked when shutting down a thread.
>
> Specifically, in tsd.c (function tsd_cleanup), this code:
>
> #define O(n, t) \
> n##_cleanup(tsd);
> MALLOC_TSD
> #undef O
> tsd->state = tsd_state_purgatory;
> tsd_set(tsd);
> break;
>
>
> The cleanup part can wind up creating an arenas_cache, then the tsd_set clears the arenas_cache pointer, and the memory is leaked away.
>
> I added this call:
>
> arenas_cache_cleanup(tsd_get());
>
> After the undef and before the tsd->state, and the leak disappears. I'm not sure if there is a better way to fix this though.
>
Fix integrated:
https://github.com/jemalloc/jemalloc/commit/39f58755a7c2c5c12c9b732c17fe472c9872ab4b
Thanks,
Jason
More information about the jemalloc-discuss
mailing list