summaryrefslogtreecommitdiff
path: root/thread_win32.c
diff options
context:
space:
mode:
authorKJ Tsanaktsidis <kj@kjtsanaktsidis.id.au>2023-11-12 13:34:43 +1100
committerKJ Tsanaktsidis <kj@kjtsanaktsidis.id.au>2024-01-12 17:29:48 +1100
commit6185cfdf38e26026c6d38220eeca48689e54cdcf (patch)
treef3d4af0fc1949270206a97217e844f1d8f5ea895 /thread_win32.c
parent4ba8f0dc993953d3ddda6328e3ef17a2fc2cbde5 (diff)
Make stack bounds detection work with ASAN
Where a local variable is used as part of the stack bounds detection, it has to actually be on the stack. ASAN can put local variable on "fake stacks", however, with addresses in different memory mappings. This completely destroys the stack bounds calculation, and can lead to e.g. things not getting GC marked on the machine stack or stackoverflow checks that always fail. The __asan_addr_is_in_fake_stack helper can be used to get the _real_ stack address of such variables, and thus perform the stack size calculation properly [Bug #20001]
Diffstat (limited to 'thread_win32.c')
-rw-r--r--thread_win32.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/thread_win32.c b/thread_win32.c
index e92472cea9..c294542003 100644
--- a/thread_win32.c
+++ b/thread_win32.c
@@ -11,6 +11,7 @@
#ifdef THREAD_SYSTEM_DEPENDENT_IMPLEMENTATION
+#include "internal/sanitizers.h"
#include <process.h>
#define TIME_QUANTUM_USEC (10 * 1000)
@@ -596,7 +597,7 @@ COMPILER_WARNING_IGNORED(-Wmaybe-uninitialized)
static inline SIZE_T
query_memory_basic_info(PMEMORY_BASIC_INFORMATION mi, void *local_in_parent_frame)
{
- return VirtualQuery(local_in_parent_frame, mi, sizeof(*mi));
+ return VirtualQuery(asan_get_real_stack_addr(local_in_parent_frame), mi, sizeof(*mi));
}
COMPILER_WARNING_POP