mirror of
https://github.com/jemalloc/jemalloc.git
synced 2026-07-22 04:03:11 +00:00
Initialize TSD tcache before enabling it
This commit is contained in:
committed by
Slobodan Predolac
parent
36f2017777
commit
54f22c83d8
@@ -131,10 +131,12 @@ TEST_BEGIN(test_tsd_reincarnation) {
|
||||
TEST_END
|
||||
|
||||
static bool tsd_bootstrap_reentrant_hook_ran;
|
||||
static unsigned tsd_bootstrap_reentrant_hook_runs;
|
||||
|
||||
static void
|
||||
tsd_bootstrap_reentrant_hook(void) {
|
||||
tsd_bootstrap_reentrant_hook_ran = true;
|
||||
tsd_bootstrap_reentrant_hook_runs++;
|
||||
test_hooks_tsd_bootstrap_hook = NULL;
|
||||
|
||||
void *p = malloc(16);
|
||||
@@ -157,12 +159,39 @@ thd_start_reentrant_tsd_bootstrap(void *arg) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void *
|
||||
thd_start_reentrant_tsd_bootstrap_minimal(void *arg) {
|
||||
(void)arg;
|
||||
|
||||
tsd_t *tsd = tsd_fetch_min();
|
||||
expect_u_eq(tsd_state_get(tsd), tsd_state_minimal_initialized,
|
||||
"TSD should be minimal initialized");
|
||||
|
||||
test_hooks_tsd_bootstrap_hook = tsd_bootstrap_reentrant_hook;
|
||||
void *p = malloc(1);
|
||||
expect_ptr_not_null(p, "Unexpected malloc() failure");
|
||||
free(p);
|
||||
test_hooks_tsd_bootstrap_hook = NULL;
|
||||
|
||||
expect_true(tsd_bootstrap_reentrant_hook_ran,
|
||||
"TSD bootstrap hook should have executed");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
TEST_BEGIN(test_tsd_reentrant_bootstrap) {
|
||||
thd_t thd;
|
||||
|
||||
tsd_bootstrap_reentrant_hook_ran = false;
|
||||
tsd_bootstrap_reentrant_hook_runs = 0;
|
||||
thd_create(&thd, thd_start_reentrant_tsd_bootstrap, NULL);
|
||||
thd_join(thd, NULL);
|
||||
|
||||
tsd_bootstrap_reentrant_hook_ran = false;
|
||||
thd_create(&thd, thd_start_reentrant_tsd_bootstrap_minimal, NULL);
|
||||
thd_join(thd, NULL);
|
||||
|
||||
expect_u_eq(tsd_bootstrap_reentrant_hook_runs, 2,
|
||||
"TSD bootstrap hook should have executed once per case");
|
||||
}
|
||||
TEST_END
|
||||
|
||||
|
||||
Reference in New Issue
Block a user