Fix more prof_tdata resurrection corner cases.

This commit is contained in:
Jason Evans 2012-04-28 23:27:13 -07:00
parent 0050a0f7e6
commit f278994029
2 changed files with 9 additions and 7 deletions

View File

@ -235,7 +235,10 @@ bool prof_boot2(void);
assert(size == s2u(size)); \ assert(size == s2u(size)); \
\ \
prof_tdata = prof_tdata_get(); \ prof_tdata = prof_tdata_get(); \
if (prof_tdata == NULL) { \ if ((uintptr_t)prof_tdata <= (uintptr_t)PROF_TDATA_STATE_MAX) { \
if (prof_tdata != NULL) \
ret = (prof_thr_cnt_t *)(uintptr_t)1U; \
else \
ret = NULL; \ ret = NULL; \
break; \ break; \
} \ } \
@ -308,8 +311,6 @@ prof_tdata_get(void)
if ((uintptr_t)prof_tdata <= (uintptr_t)PROF_TDATA_STATE_MAX) { if ((uintptr_t)prof_tdata <= (uintptr_t)PROF_TDATA_STATE_MAX) {
if (prof_tdata == NULL) if (prof_tdata == NULL)
prof_tdata = prof_tdata_init(); prof_tdata = prof_tdata_init();
else
prof_tdata = NULL;
} }
return (prof_tdata); return (prof_tdata);
@ -394,7 +395,8 @@ prof_sample_accum_update(size_t size)
assert(opt_lg_prof_sample != 0); assert(opt_lg_prof_sample != 0);
prof_tdata = *prof_tdata_tsd_get(); prof_tdata = *prof_tdata_tsd_get();
assert((uintptr_t)prof_tdata > (uintptr_t)PROF_TDATA_STATE_MAX); if ((uintptr_t)prof_tdata <= (uintptr_t)PROF_TDATA_STATE_MAX)
return (true);
/* Take care to avoid integer overflow. */ /* Take care to avoid integer overflow. */
if (size >= prof_tdata->threshold - prof_tdata->accum) { if (size >= prof_tdata->threshold - prof_tdata->accum) {

View File

@ -440,7 +440,7 @@ prof_lookup(prof_bt_t *bt)
cassert(config_prof); cassert(config_prof);
prof_tdata = prof_tdata_get(); prof_tdata = prof_tdata_get();
if (prof_tdata == NULL) if ((uintptr_t)prof_tdata <= (uintptr_t)PROF_TDATA_STATE_MAX)
return (NULL); return (NULL);
if (ckh_search(&prof_tdata->bt2cnt, bt, NULL, &ret.v)) { if (ckh_search(&prof_tdata->bt2cnt, bt, NULL, &ret.v)) {
@ -846,7 +846,7 @@ prof_dump(bool propagate_err, const char *filename, bool leakcheck)
cassert(config_prof); cassert(config_prof);
prof_tdata = prof_tdata_get(); prof_tdata = prof_tdata_get();
if (prof_tdata == NULL) if ((uintptr_t)prof_tdata <= (uintptr_t)PROF_TDATA_STATE_MAX)
return (true); return (true);
prof_enter(prof_tdata); prof_enter(prof_tdata);
prof_dump_fd = creat(filename, 0644); prof_dump_fd = creat(filename, 0644);