From 2e19b941136ebd4e1d9c4766a040d3148a55d24e Mon Sep 17 00:00:00 2001 From: Oran Agra Date: Mon, 9 Sep 2019 14:35:06 +0300 Subject: RED-31295 - redis: avoid race between dlopen and thread creation It seeems that since I added the creation of the jemalloc thread redis sometimes fails to start with the following error: Inconsistency detected by ld.so: dl-tls.c: 493: _dl_allocate_tls_init: Assertion `listp->slotinfo[cnt].gen <= GL(dl_tls_generation)' failed! This seems to be due to a race bug in ld.so, in which TLS creation on the thread, collide with dlopen. Move the creation of BIO and jemalloc threads to after modules are loaded. plus small bugfix when trying to disable the jemalloc thread at runtime --- src/zmalloc.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'src/zmalloc.c') diff --git a/src/zmalloc.c b/src/zmalloc.c index 58896a727..437f43b64 100644 --- a/src/zmalloc.c +++ b/src/zmalloc.c @@ -332,10 +332,8 @@ int zmalloc_get_allocator_info(size_t *allocated, void set_jemalloc_bg_thread(int enable) { /* let jemalloc do purging asynchronously, required when there's no traffic * after flushdb */ - if (enable) { - char val = 1; - je_mallctl("background_thread", NULL, 0, &val, 1); - } + char val = !!enable; + je_mallctl("background_thread", NULL, 0, &val, 1); } int jemalloc_purge() { -- cgit v1.2.1