diff --git a/core/unix/os.c b/core/unix/os.c index 6f4034f6c12..8b3a4091b46 100644 --- a/core/unix/os.c +++ b/core/unix/os.c @@ -2379,6 +2379,12 @@ os_tls_init(void) if (last_thread_tls_exited) /* re-attach */ last_thread_tls_exited = false; } + + /* We need to make sure that get_thread_private_dcontext() returns NULL until + * set it to something else. If CONTEXT_REBASE_OFFT is non-zero we have to + * call set_thread_private_dcontext(NULL) expilcitely, or otherwise + * get_thread_private_dcontext() will return NULL - CONTEXT_REBASE_OFFT. + */ #if (CONTEXT_REBASE_OFFT != 0) set_thread_private_dcontext(NULL); #endif