Fix a potential tsd cleanup leak.

Prior to 767d85061a (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>.
This commit is contained in:
Jason Evans 2016-02-27 21:18:15 -08:00
parent 3c07f803aa
commit 39f58755a7

View File

@ -652,6 +652,9 @@ arenas_tdata_cleanup(tsd_t *tsd)
{ {
arena_tdata_t *arenas_tdata; 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); arenas_tdata = tsd_arenas_tdata_get(tsd);
if (arenas_tdata != NULL) { if (arenas_tdata != NULL) {
tsd_arenas_tdata_set(tsd, NULL); tsd_arenas_tdata_set(tsd, NULL);