From 88d9dfe8cbe909624f21334545acd2bed35d50eb Mon Sep 17 00:00:00 2001 From: Vyacheslav Chigrin Date: Mon, 22 Sep 2025 16:50:02 +0300 Subject: [PATCH] Fix stack overflow detection during ASAN build. See discussion in issue #4638. --- core/iwasm/common/wasm_runtime_common.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/core/iwasm/common/wasm_runtime_common.c b/core/iwasm/common/wasm_runtime_common.c index 9edec17982..c7c7ce6744 100644 --- a/core/iwasm/common/wasm_runtime_common.c +++ b/core/iwasm/common/wasm_runtime_common.c @@ -7979,6 +7979,16 @@ wasm_runtime_get_module_name(wasm_module_t module) return ""; } +#if defined(__GNUC__) || defined(__clang__) +/* In few places we use addresses of local variables for estimating used stack + size. This logic conficts with ASAN, since is uses fake stack for local + variables storage. +*/ +#define NO_SANITIZE_ADDRESS __attribute__((no_sanitize_address)) +#else +# define NO_SANITIZE_ADDRESS +#endif + /* * wasm_runtime_detect_native_stack_overflow * @@ -7988,6 +7998,7 @@ wasm_runtime_get_module_name(wasm_module_t module) * * - update native_stack_top_min. */ +NO_SANITIZE_ADDRESS bool wasm_runtime_detect_native_stack_overflow(WASMExecEnv *exec_env) { @@ -8010,6 +8021,7 @@ wasm_runtime_detect_native_stack_overflow(WASMExecEnv *exec_env) return true; } +NO_SANITIZE_ADDRESS bool wasm_runtime_detect_native_stack_overflow_size(WASMExecEnv *exec_env, uint32 requested_size)