summaryrefslogtreecommitdiffstats
path: root/src/jemalloc.c
diff options
context:
space:
mode:
authorJason Evans <jasone@canonware.com>2016-02-28 05:18:15 (GMT)
committerJason Evans <jasone@canonware.com>2016-02-28 05:18:15 (GMT)
commit39f58755a7c2c5c12c9b732c17fe472c9872ab4b (patch)
tree2547eb428c7af23e6a0bfa41fc0035ea26516472 /src/jemalloc.c
parent3c07f803aa282598451eb0664cc94717b769a5e6 (diff)
downloadjemalloc-39f58755a7c2c5c12c9b732c17fe472c9872ab4b.zip
jemalloc-39f58755a7c2c5c12c9b732c17fe472c9872ab4b.tar.gz
jemalloc-39f58755a7c2c5c12c9b732c17fe472c9872ab4b.tar.bz2
Fix a potential tsd cleanup leak.
Prior to 767d85061a6fb88ec977bbcd9b429a43aff391e6 (Refactor arenas array (fixes deadlock).), it was possible under some circumstances for arena_get() to trigger recreation of the arenas cache during tsd cleanup, and the arenas cache would then be leaked. In principle a similar issue could still occur as a side effect of decay-based purging, which calls arena_tdata_get(). Fix arenas_tdata_cleanup() by setting tsd->arenas_tdata_bypass to true, so that arena_tdata_get() will gracefully fail (an expected behavior) rather than recreating tsd->arena_tdata. Reported by Christopher Ferris <cferris@google.com>.
Diffstat (limited to 'src/jemalloc.c')
-rw-r--r--src/jemalloc.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/jemalloc.c b/src/jemalloc.c
index c884178..0735376 100644
--- a/src/jemalloc.c
+++ b/src/jemalloc.c
@@ -652,6 +652,9 @@ arenas_tdata_cleanup(tsd_t *tsd)
{
arena_tdata_t *arenas_tdata;
+ /* Prevent tsd->arenas_tdata from being (re)created. */
+ *tsd_arenas_tdata_bypassp_get(tsd) = true;
+
arenas_tdata = tsd_arenas_tdata_get(tsd);
if (arenas_tdata != NULL) {
tsd_arenas_tdata_set(tsd, NULL);