diff --git a/src/luaconf.h b/src/luaconf.h index a5e54a0..e4d2340 100644 --- a/src/luaconf.h +++ b/src/luaconf.h @@ -692,6 +692,7 @@ static inline void lua_number2str(char *buf, LUA_NUMBER n) ** compiling as C++ code, with _longjmp/_setjmp when asked to use them, ** and with longjmp/setjmp otherwise. */ + #if defined(__cplusplus) /* C++ exceptions */ #define LUAI_THROW(L,c) throw(c) diff --git a/src/thrlua.h b/src/thrlua.h index 3f39d8f..e9b588b 100644 --- a/src/thrlua.h +++ b/src/thrlua.h @@ -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 +#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