Skip to content

Commit

Permalink
Update stack limit in ASan builds (#778)
Browse files Browse the repository at this point in the history
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: #671
Fixes: #775
Fixes: #776
  • Loading branch information
bnoordhuis authored Dec 30, 2024
1 parent 74fd4d7 commit 99c02eb
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 18 deletions.
4 changes: 0 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 0 additions & 8 deletions cutils.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 0 additions & 3 deletions qjs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
2 changes: 1 addition & 1 deletion quickjs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
7 changes: 7 additions & 0 deletions tests/bug775.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/*---
negative:
phase: runtime
type: RangeError
---*/
function f() { f() } // was problematic under ASan
f()
7 changes: 7 additions & 0 deletions tests/bug776.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/*---
negative:
phase: runtime
type: RangeError
---*/
function f() { f.apply(null) } // was problematic under ASan
f()
2 changes: 0 additions & 2 deletions tests/test_std.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 99c02eb

Please sign in to comment.