Conversation
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
There was a problem hiding this comment.
Pull request overview
This PR updates Lua’s longjmp-based error handling to better cooperate with AddressSanitizer by invoking an ASan “no return” hook before performing longjmp.
Changes:
- Adds a declaration for
__asan_handle_no_return. - Wraps
LUAI_THROW(for_longjmp/_setjmpandlongjmp/setjmpconfigurations) to call__asan_handle_no_return()beforelua_do_longjmp.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
src/luaconf.h
Outdated
|
|
||
| void __asan_handle_no_return(void); | ||
|
|
There was a problem hiding this comment.
__asan_handle_no_return is declared unconditionally, but the symbol is only provided when linking with the ASan runtime. In non-ASan builds this will either cause a link error once referenced, or at minimum introduces an undocumented dependency. Consider wrapping the declaration (and any calls) in an ASan feature check (e.g. __SANITIZE_ADDRESS__ or __has_feature(address_sanitizer)), and define a no-op fallback when ASan is not enabled; alternatively include sanitizer/asan_interface.h conditionally when available.
| /* in Unix, try _longjmp/_setjmp (more efficient) */ | ||
| #define LUAI_THROW(L,c) lua_do_longjmp((c)->b, 1) | ||
| #define LUAI_THROW(L,c) do { __asan_handle_no_return(); lua_do_longjmp((c)->b, 1); } while(0) | ||
| #define LUAI_TRY(L,c,a) if (lua_do_setjmp((c)->b) == 0) { a } |
There was a problem hiding this comment.
LUAI_THROW now unconditionally calls __asan_handle_no_return(). Without guarding this call behind an AddressSanitizer-enabled compile check (or providing a no-op fallback), non-ASan builds can fail to link or may inadvertently require the ASan runtime. Gate the call behind an __SANITIZE_ADDRESS__/__has_feature(address_sanitizer) check or similar.
| /* default handling with long jumps */ | ||
| #define LUAI_THROW(L,c) lua_do_longjmp((c)->b, 1) | ||
| #define LUAI_THROW(L,c) do { __asan_handle_no_return(); lua_do_longjmp((c)->b, 1); } while(0) | ||
| #define LUAI_TRY(L,c,a) if (lua_do_setjmp((c)->b) == 0) { a } |
There was a problem hiding this comment.
Same issue as above: this LUAI_THROW variant calls __asan_handle_no_return() unconditionally, which can break non-ASan builds. Please guard it behind an ASan-enabled macro check or provide a no-op fallback when ASan is not active.

Note
Low Risk
Low risk because behavior only changes when building with
__SANITIZE_ADDRESS__, swapping in standardsetjmp/longjmpto avoid ASAN false positives; non-ASAN builds keep the existing asm fast-paths.Overview
When building under AddressSanitizer, the runtime now avoids the custom asm
setjmp/longjmpimplementations and instead uses the systemsetjmp/longjmpso ASAN can correctly intercept them and unpoison skipped stack frames.Non-ASAN builds continue to use the architecture-specific asm versions (
x86_64,i386,aarch64) as before.Written by Cursor Bugbot for commit d6b2e67. This will update automatically on new commits. Configure here.