Fix the lock owner sanity checking during background thread boot.

During boot, some mutexes are not initialized yet, plus there's no point taking
many mutexes while everything is covered by the global init lock, so the locking
assumptions in some functions (e.g. background_thread_enabled_set()) can't be
enforced.  Skip the lock owner check in this case.
This commit is contained in:
Qi Wang
2024-09-20 20:24:30 -07:00
committed by Qi Wang
parent 0181aaa495
commit 44db479fad
2 changed files with 8 additions and 3 deletions

View File

@@ -819,7 +819,6 @@ background_thread_boot1(tsdn_t *tsdn, base_t *base) {
}
max_background_threads = opt_max_background_threads;
background_thread_enabled_set(tsdn, opt_background_thread);
if (malloc_mutex_init(&background_thread_lock,
"background_thread_global",
WITNESS_RANK_BACKGROUND_THREAD_GLOBAL,
@@ -850,7 +849,8 @@ background_thread_boot1(tsdn_t *tsdn, base_t *base) {
background_thread_info_init(tsdn, info);
malloc_mutex_unlock(tsdn, &info->mtx);
}
/* Using _impl to bypass the locking check during init. */
background_thread_enabled_set_impl(opt_background_thread);
#endif
return false;
}