Skip to content

Commit

Permalink
Re-enable stack depth checks under ASan
Browse files Browse the repository at this point in the history
Add a fudge factor to the stack size calculation because stack frames
are bigger when running under AddressSanitizer.
  • Loading branch information
bnoordhuis committed Nov 30, 2023
1 parent bfd8c38 commit 1f21fcd
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion quickjs.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
#define CONFIG_PRINTF_RNDN
#endif

#if !defined(EMSCRIPTEN) && !defined(__ASAN__)
#if !defined(EMSCRIPTEN)
/* enable stack limitation */
#define CONFIG_STACK_CHECK
#endif
Expand Down Expand Up @@ -1576,6 +1576,9 @@ static inline uintptr_t js_get_stack_pointer(void)
static inline BOOL js_check_stack_overflow(JSRuntime *rt, size_t alloca_size)
{
uintptr_t sp;
#ifdef __ASAN__
alloca_size *= 2; // stack frames are bigger under AddressSanitizer
#endif
sp = js_get_stack_pointer() - alloca_size;
return unlikely(sp < rt->stack_limit);
}
Expand Down

0 comments on commit 1f21fcd

Please sign in to comment.