From 99c02eb45170775a9a679c32b45dd4000ea67aff Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Mon, 30 Dec 2024 11:29:22 +0100 Subject: [PATCH] Update stack limit in ASan builds (#778) Otherwise recursive calls keep going until they trip ASan checks. Remove the `__ASAN__` and `__UBSAN__` defines; no longer necessary. Remove `globalThis.__running_with_sanitizer__` from qjs; likewise. Fixes: https://github.com/quickjs-ng/quickjs/issues/671 Fixes: https://github.com/quickjs-ng/quickjs/issues/775 Fixes: https://github.com/quickjs-ng/quickjs/issues/776 --- CMakeLists.txt | 4 ---- cutils.h | 8 -------- qjs.c | 3 --- quickjs.c | 2 +- tests/bug775.js | 7 +++++++ tests/bug776.js | 7 +++++++ tests/test_std.js | 2 -- 7 files changed, 15 insertions(+), 18 deletions(-) create mode 100644 tests/bug775.js create mode 100644 tests/bug776.js diff --git a/CMakeLists.txt b/CMakeLists.txt index 66ad2dc..11b2e2c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -165,10 +165,6 @@ endif() if(CONFIG_UBSAN) message(STATUS "Building with UBSan") -# __has_feature(undefined_sanitizer) or __SANITIZE_UNDEFINED__ don't exist -add_compile_definitions( - __UBSAN__=1 -) add_compile_options( -fsanitize=undefined -fno-sanitize-recover=all diff --git a/cutils.h b/cutils.h index 4ad3f64..ea22834 100644 --- a/cutils.h +++ b/cutils.h @@ -54,14 +54,6 @@ extern "C" { #include #endif -#if defined(__SANITIZE_ADDRESS__) -# define __ASAN__ 1 -#elif defined(__has_feature) -# if __has_feature(address_sanitizer) -# define __ASAN__ 1 -# endif -#endif - #if defined(_MSC_VER) && !defined(__clang__) # define likely(x) (x) # define unlikely(x) (x) diff --git a/qjs.c b/qjs.c index 8671ffb..a4851bd 100644 --- a/qjs.c +++ b/qjs.c @@ -208,9 +208,6 @@ static const JSCFunctionListEntry navigator_proto_funcs[] = { static const JSCFunctionListEntry global_obj[] = { JS_CFUNC_DEF("gc", 0, js_gc), -#if defined(__ASAN__) || defined(__UBSAN__) - JS_PROP_INT32_DEF("__running_with_sanitizer__", 1, JS_PROP_C_W_E ), -#endif }; /* also used to initialize the worker context */ diff --git a/quickjs.c b/quickjs.c index d0ca626..984ab45 100644 --- a/quickjs.c +++ b/quickjs.c @@ -2517,7 +2517,7 @@ JSRuntime *JS_GetRuntime(JSContext *ctx) static void update_stack_limit(JSRuntime *rt) { -#if defined(__wasi__) || (defined(__ASAN__) && !defined(NDEBUG)) +#if defined(__wasi__) rt->stack_limit = 0; /* no limit */ #else if (rt->stack_size == 0) { diff --git a/tests/bug775.js b/tests/bug775.js new file mode 100644 index 0000000..4cb9387 --- /dev/null +++ b/tests/bug775.js @@ -0,0 +1,7 @@ +/*--- +negative: + phase: runtime + type: RangeError +---*/ +function f() { f() } // was problematic under ASan +f() diff --git a/tests/bug776.js b/tests/bug776.js new file mode 100644 index 0000000..4b092c2 --- /dev/null +++ b/tests/bug776.js @@ -0,0 +1,7 @@ +/*--- +negative: + phase: runtime + type: RangeError +---*/ +function f() { f.apply(null) } // was problematic under ASan +f() diff --git a/tests/test_std.js b/tests/test_std.js index 0f70c6d..4603590 100644 --- a/tests/test_std.js +++ b/tests/test_std.js @@ -258,8 +258,6 @@ function test_timeout() function test_timeout_order() { - if (globalThis.__running_with_sanitizer__) return; - var s = ""; os.setTimeout(a, 0); os.setTimeout(b, 100);