Fall back to the default pthread_create if RTLD_NEXT fails.
This commit is contained in:
parent
d1e11d48d4
commit
77a71ef2b7
@ -8,7 +8,6 @@ extern atomic_b_t background_thread_enabled_state;
|
||||
extern size_t n_background_threads;
|
||||
extern size_t max_background_threads;
|
||||
extern background_thread_info_t *background_thread_info;
|
||||
extern bool can_enable_background_thread;
|
||||
|
||||
bool background_thread_create(tsd_t *tsd, unsigned arena_ind);
|
||||
bool background_threads_enable(tsd_t *tsd);
|
||||
|
@ -22,9 +22,6 @@ size_t max_background_threads;
|
||||
/* Thread info per-index. */
|
||||
background_thread_info_t *background_thread_info;
|
||||
|
||||
/* False if no necessary runtime support. */
|
||||
bool can_enable_background_thread;
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
#ifdef JEMALLOC_PTHREAD_CREATE_WRAPPER
|
||||
@ -812,16 +809,21 @@ pthread_create_fptr_init(void) {
|
||||
if (pthread_create_fptr != NULL) {
|
||||
return false;
|
||||
}
|
||||
/*
|
||||
* Try the next symbol first, because 1) when use lazy_lock we have a
|
||||
* wrapper for pthread_create; and 2) application may define its own
|
||||
* wrapper as well (and can call malloc within the wrapper).
|
||||
*/
|
||||
pthread_create_fptr = dlsym(RTLD_NEXT, "pthread_create");
|
||||
if (pthread_create_fptr == NULL) {
|
||||
can_enable_background_thread = false;
|
||||
if (config_lazy_lock || opt_background_thread) {
|
||||
if (config_lazy_lock) {
|
||||
malloc_write("<jemalloc>: Error in dlsym(RTLD_NEXT, "
|
||||
"\"pthread_create\")\n");
|
||||
abort();
|
||||
} else {
|
||||
/* Fall back to the default symbol. */
|
||||
pthread_create_fptr = pthread_create;
|
||||
}
|
||||
} else {
|
||||
can_enable_background_thread = true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
14
src/ctl.c
14
src/ctl.c
@ -1556,13 +1556,6 @@ background_thread_ctl(tsd_t *tsd, const size_t *mib, size_t miblen,
|
||||
|
||||
background_thread_enabled_set(tsd_tsdn(tsd), newval);
|
||||
if (newval) {
|
||||
if (!can_enable_background_thread) {
|
||||
malloc_printf("<jemalloc>: Error in dlsym("
|
||||
"RTLD_NEXT, \"pthread_create\"). Cannot "
|
||||
"enable background_thread\n");
|
||||
ret = EFAULT;
|
||||
goto label_return;
|
||||
}
|
||||
if (background_threads_enable(tsd)) {
|
||||
ret = EFAULT;
|
||||
goto label_return;
|
||||
@ -1617,13 +1610,6 @@ max_background_threads_ctl(tsd_t *tsd, const size_t *mib, size_t miblen,
|
||||
}
|
||||
|
||||
if (background_thread_enabled()) {
|
||||
if (!can_enable_background_thread) {
|
||||
malloc_printf("<jemalloc>: Error in dlsym("
|
||||
"RTLD_NEXT, \"pthread_create\"). Cannot "
|
||||
"enable background_thread\n");
|
||||
ret = EFAULT;
|
||||
goto label_return;
|
||||
}
|
||||
background_thread_enabled_set(tsd_tsdn(tsd), false);
|
||||
if (background_threads_disable(tsd)) {
|
||||
ret = EFAULT;
|
||||
|
Loading…
Reference in New Issue
Block a user