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
This commit is contained in:
Ben Noordhuis 2024-12-30 11:29:22 +01:00 committed by GitHub
parent 74fd4d7dc9
commit 99c02eb451
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 15 additions and 18 deletions

View file

@ -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

View file

@ -54,14 +54,6 @@ extern "C" {
#include <pthread.h>
#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)

3
qjs.c
View file

@ -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 */

View file

@ -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) {

7
tests/bug775.js Normal file
View file

@ -0,0 +1,7 @@
/*---
negative:
phase: runtime
type: RangeError
---*/
function f() { f() } // was problematic under ASan
f()

7
tests/bug776.js Normal file
View file

@ -0,0 +1,7 @@
/*---
negative:
phase: runtime
type: RangeError
---*/
function f() { f.apply(null) } // was problematic under ASan
f()

View file

@ -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);