diff options
author | Qi Wang <interwq@gwu.edu> | 2017-06-14 19:12:23 (GMT) |
---|---|---|
committer | Qi Wang <interwq@gmail.com> | 2017-06-14 20:27:41 (GMT) |
commit | a4d6fe73cf07b3be3af6b7811cfc5950320bb37f (patch) | |
tree | 628e577b980030412edf2316cfcab1da05c48df0 /src | |
parent | bdcf40a6208962008010c30463dc7dbddf3fc564 (diff) | |
download | jemalloc-a4d6fe73cf07b3be3af6b7811cfc5950320bb37f.zip jemalloc-a4d6fe73cf07b3be3af6b7811cfc5950320bb37f.tar.gz jemalloc-a4d6fe73cf07b3be3af6b7811cfc5950320bb37f.tar.bz2 |
Only abort on dlsym when necessary.
If neither background_thread nor lazy_lock is in use, do not abort on dlsym
errors.
Diffstat (limited to 'src')
-rw-r--r-- | src/background_thread.c | 14 | ||||
-rw-r--r-- | src/ctl.c | 7 |
2 files changed, 18 insertions, 3 deletions
diff --git a/src/background_thread.c b/src/background_thread.c index a7403b8..1ff5944 100644 --- a/src/background_thread.c +++ b/src/background_thread.c @@ -20,6 +20,9 @@ size_t n_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 @@ -785,9 +788,14 @@ background_thread_boot0(void) { #ifdef JEMALLOC_PTHREAD_CREATE_WRAPPER pthread_create_fptr = dlsym(RTLD_NEXT, "pthread_create"); if (pthread_create_fptr == NULL) { - malloc_write("<jemalloc>: Error in dlsym(RTLD_NEXT, " - "\"pthread_create\")\n"); - abort(); + can_enable_background_thread = false; + if (config_lazy_lock || opt_background_thread) { + malloc_write("<jemalloc>: Error in dlsym(RTLD_NEXT, " + "\"pthread_create\")\n"); + abort(); + } + } else { + can_enable_background_thread = true; } #endif 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); 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; |