From 945a7b69f11e53341766442809d6663038a9989e Mon Sep 17 00:00:00 2001 From: John Sully Date: Mon, 29 Jul 2019 15:08:41 -0400 Subject: [PATCH] Fix crash in RediSearch Former-commit-id: cbe5c04a0f3b0b1886f6c88c0a2401e0e6501b3b --- src/module.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/module.cpp b/src/module.cpp index 052c8744a..b2c19c735 100644 --- a/src/module.cpp +++ b/src/module.cpp @@ -3949,6 +3949,8 @@ void RM_FreeThreadSafeContext(RedisModuleCtx *ctx) { void RM_ThreadSafeContextLock(RedisModuleCtx *ctx) { UNUSED(ctx); moduleAcquireGIL(FALSE /*fServerThread*/); + if (serverTL == nullptr) + serverTL = &g_pserver->rgthreadvar[IDX_EVENT_LOOP_MAIN]; // arbitrary module threads get the main thread context } /* Release the server lock after a thread safe API call was executed. */