From f51dae32edbd96c0a1cf7d2f0d752487e3c2d2d2 Mon Sep 17 00:00:00 2001 From: Marios Asiminakis Date: Tue, 11 Feb 2025 11:42:17 +0200 Subject: [PATCH] Comment on why set_thread_private_dcontext(NULL) is needed --- core/unix/os.c | 6 ++++++ 1 file changed, 6 insertions(+) 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