diff options
author | Jason Evans <jasone@canonware.com> | 2015-09-10 06:16:10 (GMT) |
---|---|---|
committer | Jason Evans <jasone@canonware.com> | 2015-09-10 06:16:10 (GMT) |
commit | a00b10735a80f7070714b278c8acdad4473bea69 (patch) | |
tree | 85f469d89b9d910272bd1541bfa8e8cf216281f7 /src/prof.c | |
parent | a306a60651db0bd835d4009271e0be236b450fb3 (diff) | |
download | jemalloc-a00b10735a80f7070714b278c8acdad4473bea69.zip jemalloc-a00b10735a80f7070714b278c8acdad4473bea69.tar.gz jemalloc-a00b10735a80f7070714b278c8acdad4473bea69.tar.bz2 |
Fix "prof.reset" mallctl-related corruption.
Fix heap profiling to distinguish among otherwise identical sample sites
with interposed resets (triggered via the "prof.reset" mallctl). This
bug could cause data structure corruption that would most likely result
in a segfault.
Diffstat (limited to 'src/prof.c')
-rw-r--r-- | src/prof.c | 14 |
1 files changed, 11 insertions, 3 deletions
@@ -139,9 +139,16 @@ prof_tctx_comp(const prof_tctx_t *a, const prof_tctx_t *b) uint64_t b_thr_uid = b->thr_uid; int ret = (a_thr_uid > b_thr_uid) - (a_thr_uid < b_thr_uid); if (ret == 0) { - uint64_t a_tctx_uid = a->tctx_uid; - uint64_t b_tctx_uid = b->tctx_uid; - ret = (a_tctx_uid > b_tctx_uid) - (a_tctx_uid < b_tctx_uid); + uint64_t a_thr_discrim = a->thr_discrim; + uint64_t b_thr_discrim = b->thr_discrim; + ret = (a_thr_discrim > b_thr_discrim) - (a_thr_discrim < + b_thr_discrim); + if (ret == 0) { + uint64_t a_tctx_uid = a->tctx_uid; + uint64_t b_tctx_uid = b->tctx_uid; + ret = (a_tctx_uid > b_tctx_uid) - (a_tctx_uid < + b_tctx_uid); + } } return (ret); } @@ -791,6 +798,7 @@ prof_lookup(tsd_t *tsd, prof_bt_t *bt) } ret.p->tdata = tdata; ret.p->thr_uid = tdata->thr_uid; + ret.p->thr_discrim = tdata->thr_discrim; memset(&ret.p->cnts, 0, sizeof(prof_cnt_t)); ret.p->gctx = gctx; ret.p->tctx_uid = tdata->tctx_uid_next++; |