Add TSD bootstrap reentrancy test

This commit is contained in:
Farid Zakaria 2026-07-02 13:00:30 -07:00 committed by Slobodan Predolac
parent 7c34a482c1
commit 95c2588191

View file

@ -130,6 +130,42 @@ TEST_BEGIN(test_tsd_reincarnation) {
}
TEST_END
static bool tsd_bootstrap_reentrant_hook_ran;
static void
tsd_bootstrap_reentrant_hook(void) {
tsd_bootstrap_reentrant_hook_ran = true;
test_hooks_tsd_bootstrap_hook = NULL;
void *p = malloc(16);
expect_ptr_not_null(p, "Unexpected recursive malloc() failure");
free(p);
}
static void *
thd_start_reentrant_tsd_bootstrap(void *arg) {
(void)arg;
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;
thd_create(&thd, thd_start_reentrant_tsd_bootstrap, NULL);
thd_join(thd, NULL);
}
TEST_END
static void *
thd_start_dalloc_only(void *arg) {
void **ptrs = (void **)arg;
@ -194,5 +230,6 @@ main(void) {
}
return test_no_reentrancy(test_tsd_main_thread, test_tsd_sub_thread,
test_tsd_sub_thread_dalloc_only, test_tsd_reincarnation);
test_tsd_sub_thread_dalloc_only, test_tsd_reincarnation,
test_tsd_reentrant_bootstrap);
}