Don't dereference NULL tdata in prof_{enter,leave}().

It is possible for the thread's tdata to be NULL late during thread
destruction, so take care not to dereference a NULL pointer in such
cases.
This commit is contained in:
Jason Evans 2014-11-01 00:20:28 -07:00
parent d7a9bab92d
commit 82cb603ed7

View File

@ -253,8 +253,10 @@ prof_enter(tsd_t *tsd, prof_tdata_t *tdata)
cassert(config_prof); cassert(config_prof);
assert(tdata == prof_tdata_get(tsd, false)); assert(tdata == prof_tdata_get(tsd, false));
if (tdata != NULL) {
assert(!tdata->enq); assert(!tdata->enq);
tdata->enq = true; tdata->enq = true;
}
malloc_mutex_lock(&bt2gctx_mtx); malloc_mutex_lock(&bt2gctx_mtx);
} }
@ -262,13 +264,15 @@ prof_enter(tsd_t *tsd, prof_tdata_t *tdata)
JEMALLOC_INLINE_C void JEMALLOC_INLINE_C void
prof_leave(tsd_t *tsd, prof_tdata_t *tdata) prof_leave(tsd_t *tsd, prof_tdata_t *tdata)
{ {
bool idump, gdump;
cassert(config_prof); cassert(config_prof);
assert(tdata == prof_tdata_get(tsd, false)); assert(tdata == prof_tdata_get(tsd, false));
malloc_mutex_unlock(&bt2gctx_mtx); malloc_mutex_unlock(&bt2gctx_mtx);
if (tdata != NULL) {
bool idump, gdump;
assert(tdata->enq); assert(tdata->enq);
tdata->enq = false; tdata->enq = false;
idump = tdata->enq_idump; idump = tdata->enq_idump;
@ -280,6 +284,7 @@ prof_leave(tsd_t *tsd, prof_tdata_t *tdata)
prof_idump(); prof_idump();
if (gdump) if (gdump)
prof_gdump(); prof_gdump();
}
} }
#ifdef JEMALLOC_PROF_LIBUNWIND #ifdef JEMALLOC_PROF_LIBUNWIND