Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/thrlua.h
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,15 @@ struct lua_longjmp {
# define LUA_ASMNAME(x) _##x
#endif

#if LUA_ARCH_X86_64
/*
** Under AddressSanitizer, use system setjmp/longjmp so ASAN can
** intercept them and properly unpoison skipped stack frames.
** The custom asm versions bypass ASAN and cause false positives.
*/
#if defined(__SANITIZE_ADDRESS__)
# define lua_do_setjmp setjmp
# define lua_do_longjmp longjmp
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ASAN detection misses Clang before version 21

Low Severity

The ASAN check uses only __SANITIZE_ADDRESS__, which GCC has supported since 4.8 but Clang only added in version 21 (2026). Clang versions before 21 use __has_feature(address_sanitizer) instead. Builds with older Clang and -fsanitize=address will silently skip this block and continue using the custom asm setjmp/longjmp, defeating the purpose of the ASAN fix. The common portable pattern checks both: defined(__SANITIZE_ADDRESS__) || (defined(__has_feature) && __has_feature(address_sanitizer)).

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 27c45ad. Configure here.

#elif LUA_ARCH_X86_64
# define lua_do_setjmp LUA_ASMNAME(lua_setjmp_amd64)
# define lua_do_longjmp LUA_ASMNAME(lua_longjmp_amd64)
#elif LUA_ARCH_I386
Expand Down