[Tarantool-patches] [PATCH luajit v2 4/5] build: introduce LUAJIT_USE_ASAN option

Sergey Bronnikov sergeyb at tarantool.org
Mon Jul 24 14:41:09 MSK 2023


Thanks for the patch! See comments below.


On 7/21/23 11:12, Igor Munkin wrote:
> There was neither a special option nor a variable to configure the
> sanitizers support via the build system since the commit
> 052c1a32a5e74b337686eee229d089d576775931 ("Add preliminary ASAN
> support") where ASan support had been introduced. We finally decided to
> use this feature in LuaJIT CI, so for convenient build configuration
> LUAJIT_USE_ASAN option is added to the root CMakeLists.txt.
>
> Resolves tarantool/tarantool#5878
>
> Co-authored-by: Sergey Kaplun <skaplun at tarantool.org>
> Signed-off-by: Igor Munkin <imun at tarantool.org>
> ---
>   CMakeLists.txt | 33 ++++++++++++++++++++++++---------
>   1 file changed, 24 insertions(+), 9 deletions(-)
>
> diff --git a/CMakeLists.txt b/CMakeLists.txt
> index 6ef24bba..c4664cf9 100644
> --- a/CMakeLists.txt
> +++ b/CMakeLists.txt

<snipped>


> +# ASan enabled.
> +option(LUAJIT_USE_ASAN "Build LuaJIT with AddressSanitizer" OFF)
> +if(LUAJIT_USE_ASAN)
> +  if(NOT LUAJIT_USE_SYSMALLOC)
> +    message(WARNING
> +      "Unfortunately, internal LuaJIT memory allocator is not instrumented yet,"
> +      " so to find any memory errors it's better to build LuaJIT with system"
> +      " provided memory allocator (i.e. run CMake configuration phase with"
> +      " -DLUAJIT_USE_SYSMALLOC=ON)."
> +    )
> +  endif()
> +  # Use all recomendations described in AddressSanitize docs:

typo: recomendations -> recommendations


<snipped>


With applied patch tests below failed:


LUA_PATH="test/tarantool-tests/?.lua;src/?.lua;;./src/jit/?.lua;./tools/?.lua;" 
./src/luajit test/tarantool-tests/lj-128-fix-union-init.test.lua


=================================================================
==558476==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 2048 byte(s) in 1 object(s) allocated from:
     #0 0x55f75b19c1f5 in realloc 
(/home/sergeyb/sources/MRG/tarantool/third_party/luajit/src/luajit+0xd81f5) 
(BuildId: 3f595aa9bf0b93395cadf9c7246b933ded2a6a0e)
     #1 0x55f75b230295 in mem_alloc lib_aux.c
     #2 0x55f75b205066 in lj_mem_realloc 
(/home/sergeyb/sources/MRG/tarantool/third_party/luajit/src/luajit+0x141066) 
(BuildId: 3f595aa9bf0b93395cadf9c7246b933ded2a6a0e)
     #3 0x55f75b2aa6fb in lj_ir_growbot lj_ir.c
     #4 0x55f75b2a78de in lj_ir_kgc 
(/home/sergeyb/sources/MRG/tarantool/third_party/luajit/src/luajit+0x1e38de) 
(BuildId: 3f595aa9bf0b93395cadf9c7246b933ded2a6a0e)
     #5 0x55f75b37f7c7 in lj_record_constify 
(/home/sergeyb/sources/MRG/tarantool/third_party/luajit/src/luajit+0x2bb7c7) 
(BuildId: 3f595aa9bf0b93395cadf9c7246b933ded2a6a0e)
     #6 0x55f75b398876 in rec_upvalue lj_record.c
     #7 0x55f75b3923db in lj_record_ins 
(/home/sergeyb/sources/MRG/tarantool/third_party/luajit/src/luajit+0x2ce3db) 
(BuildId: 3f595aa9bf0b93395cadf9c7246b933ded2a6a0e)
     #8 0x55f75b2ae826 in trace_state lj_trace.c
     #9 0x55f75b335eb4 in lj_vm_cpcall 
(/home/sergeyb/sources/MRG/tarantool/third_party/luajit/src/luajit+0x271eb4) 
(BuildId: 3f595aa9bf0b93395cadf9c7246b933ded2a6a0e)

SUMMARY: AddressSanitizer: 2048 byte(s) leaked in 1 allocation(s).


$ 
LUA_PATH="test/tarantool-tests/?.lua;src/?.lua;;./src/jit/?.lua;./tools/?.lua;" 
./src/luajit test/tarantool-tests/lj-1024-varg-maxslot.test.lua
TAP version 13
1..2
ok - BC_VARG recording 0th frame depth
ok - BC_VARG recording with VARG slots defined on trace

=================================================================
==558552==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 2048 byte(s) in 1 object(s) allocated from:
     #0 0x55db03d981f5 in realloc 
(/home/sergeyb/sources/MRG/tarantool/third_party/luajit/src/luajit+0xd81f5) 
(BuildId: 3f595aa9bf0b93395cadf9c7246b933ded2a6a0e)
     #1 0x55db03e2c295 in mem_alloc lib_aux.c
     #2 0x55db03e01066 in lj_mem_realloc 
(/home/sergeyb/sources/MRG/tarantool/third_party/luajit/src/luajit+0x141066) 
(BuildId: 3f595aa9bf0b93395cadf9c7246b933ded2a6a0e)
     #3 0x55db03ea66fb in lj_ir_growbot lj_ir.c
     #4 0x55db03ea38de in lj_ir_kgc 
(/home/sergeyb/sources/MRG/tarantool/third_party/luajit/src/luajit+0x1e38de) 
(BuildId: 3f595aa9bf0b93395cadf9c7246b933ded2a6a0e)
     #5 0x55db03f8c4f2 in lj_record_ins 
(/home/sergeyb/sources/MRG/tarantool/third_party/luajit/src/luajit+0x2cc4f2) 
(BuildId: 3f595aa9bf0b93395cadf9c7246b933ded2a6a0e)
     #6 0x55db03eaa826 in trace_state lj_trace.c
     #7 0x55db03f31eb4 in lj_vm_cpcall 
(/home/sergeyb/sources/MRG/tarantool/third_party/luajit/src/luajit+0x271eb4) 
(BuildId: 3f595aa9bf0b93395cadf9c7246b933ded2a6a0e)

SUMMARY: AddressSanitizer: 2048 byte(s) leaked in 1 allocation(s).



More information about the Tarantool-patches mailing list