Skip to content

Commit db72eea

Browse files
committed
Fix stack overflow detection during ASAN build.
See discussion in issue #4638.
1 parent a6a9f1f commit db72eea

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

core/iwasm/common/wasm_runtime_common.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7884,6 +7884,24 @@ wasm_runtime_get_module_name(wasm_module_t module)
78847884
bool
78857885
wasm_runtime_detect_native_stack_overflow(WASMExecEnv *exec_env)
78867886
{
7887+
#if defined(__has_feature)
7888+
#if __has_feature(address_sanitizer)
7889+
// ASAN build with clang++
7890+
#define BUILD_ASAN 1
7891+
#endif
7892+
#endif
7893+
7894+
#ifdef __SANITIZE_ADDRESS__
7895+
// ASAN build with g++
7896+
#define BUILD_ASAN 1
7897+
#endif
7898+
7899+
#ifdef BUILD_ASAN
7900+
// ASAN uses fake stack for local variables storage, so we can not
7901+
// properly detect stack overflow with it.
7902+
return true;
7903+
#undef BUILD_ASAN
7904+
#endif
78877905
uint8 *boundary = exec_env->native_stack_boundary;
78887906
RECORD_STACK_USAGE(exec_env, (uint8 *)&boundary);
78897907
if (boundary == NULL) {

0 commit comments

Comments
 (0)