Only abort on dlsym when necessary.
If neither background_thread nor lazy_lock is in use, do not abort on dlsym errors.
This commit is contained in:
parent
bdcf40a620
commit
a4d6fe73cf
@ -6,6 +6,7 @@ extern malloc_mutex_t background_thread_lock;
|
|||||||
extern atomic_b_t background_thread_enabled_state;
|
extern atomic_b_t background_thread_enabled_state;
|
||||||
extern size_t n_background_threads;
|
extern size_t n_background_threads;
|
||||||
extern background_thread_info_t *background_thread_info;
|
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_thread_create(tsd_t *tsd, unsigned arena_ind);
|
||||||
bool background_threads_enable(tsd_t *tsd);
|
bool background_threads_enable(tsd_t *tsd);
|
||||||
|
@ -20,6 +20,9 @@ size_t n_background_threads;
|
|||||||
/* Thread info per-index. */
|
/* Thread info per-index. */
|
||||||
background_thread_info_t *background_thread_info;
|
background_thread_info_t *background_thread_info;
|
||||||
|
|
||||||
|
/* False if no necessary runtime support. */
|
||||||
|
bool can_enable_background_thread;
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
#ifdef JEMALLOC_PTHREAD_CREATE_WRAPPER
|
#ifdef JEMALLOC_PTHREAD_CREATE_WRAPPER
|
||||||
@ -785,9 +788,14 @@ background_thread_boot0(void) {
|
|||||||
#ifdef JEMALLOC_PTHREAD_CREATE_WRAPPER
|
#ifdef JEMALLOC_PTHREAD_CREATE_WRAPPER
|
||||||
pthread_create_fptr = dlsym(RTLD_NEXT, "pthread_create");
|
pthread_create_fptr = dlsym(RTLD_NEXT, "pthread_create");
|
||||||
if (pthread_create_fptr == NULL) {
|
if (pthread_create_fptr == NULL) {
|
||||||
malloc_write("<jemalloc>: Error in dlsym(RTLD_NEXT, "
|
can_enable_background_thread = false;
|
||||||
"\"pthread_create\")\n");
|
if (config_lazy_lock || opt_background_thread) {
|
||||||
abort();
|
malloc_write("<jemalloc>: Error in dlsym(RTLD_NEXT, "
|
||||||
|
"\"pthread_create\")\n");
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
can_enable_background_thread = true;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
return false;
|
return false;
|
||||||
|
@ -1522,6 +1522,13 @@ background_thread_ctl(tsd_t *tsd, const size_t *mib, size_t miblen,
|
|||||||
|
|
||||||
background_thread_enabled_set(tsd_tsdn(tsd), newval);
|
background_thread_enabled_set(tsd_tsdn(tsd), newval);
|
||||||
if (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)) {
|
if (background_threads_enable(tsd)) {
|
||||||
ret = EFAULT;
|
ret = EFAULT;
|
||||||
goto label_return;
|
goto label_return;
|
||||||
|
Loading…
Reference in New Issue
Block a user