Skip to content

Bump luzer with sanitizers support #133

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

ligurio
Copy link
Owner

@ligurio ligurio commented May 30, 2025

Depends on ligurio/luzer#38.

@ligurio ligurio force-pushed the ligurio/gh-xxxx-bump-luzer-sanitizers branch from 2c7a363 to 9fc045c Compare June 2, 2025 09:37
Copy link
Collaborator

@Buristan Buristan left a comment

Choose a reason for hiding this comment

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

Hi, Sergey!
Thanks for the patchset!
I'll proceed with the review per-patch below.


[PATCH 1/2] cmake: replace string with env as a list

Generally LGTM, with one nit below.

Copy link
Collaborator

@Buristan Buristan left a comment

Choose a reason for hiding this comment

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

[PATCH 2/2] cmake: support ASAN/UBSan in lapi tests

LGTM, with a few comments below.

@@ -26,7 +26,7 @@ endif()

ExternalProject_Add(bundled-luzer
GIT_REPOSITORY https://github.com/ligurio/luzer
GIT_TAG 82d41c5f350296ca351e785a24c914165a0e8033
GIT_TAG ligurio/gh-xxxx-build-sanitizer-libs
Copy link
Collaborator

Choose a reason for hiding this comment

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

Don't forget to update this part after the ligurio/luzer#38 is merged.

Copy link
Owner Author

Choose a reason for hiding this comment

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

Added a reminder as a separate commit:

commit 94b11bbd294525c5543ff1999f7b241a2903f1c8 (HEAD -> ligurio/gh-xxxx-bump-luzer-sanitizers)
Author: Sergey Bronnikov <[email protected]>
Date:   Mon Jun 9 17:01:31 2025 +0300

    cmake: bump luzer version [TODO]
    
    Must be updated after merging https://github.com/ligurio/luzer/pull/38

diff --git a/cmake/BuildLuzer.cmake b/cmake/BuildLuzer.cmake
index a55e7ce..e37edfb 100644
--- a/cmake/BuildLuzer.cmake
+++ b/cmake/BuildLuzer.cmake
@@ -26,7 +26,7 @@ endif()
 
 ExternalProject_Add(bundled-luzer
     GIT_REPOSITORY https://github.com/ligurio/luzer
-    GIT_TAG 82d41c5f350296ca351e785a24c914165a0e8033
+    GIT_TAG ligurio/gh-xxxx-build-sanitizer-libs
     GIT_PROGRESS TRUE
     GIT_SHALLOW FALSE
     SOURCE_DIR ${LUZER_DIR}/source

Copy link
Collaborator

Choose a reason for hiding this comment

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

It may be done now.

@ligurio
Copy link
Owner Author

ligurio commented Jun 11, 2025

C stack overflow:

LUA_PATH="/home/sergeyb/sources/lua-c-api-tests/build/luzer/source/?/init.lua;/home/sergeyb/sources/lua-c-api-tests/tests/lapi/?.lua;;" LUA_CPATH="/home/sergeyb/sources/lua-c-api-tests/build/luzer/build/luzer/?.so;;" LD_PRELOAD=/home/sergeyb/sources/lua-c-api-tests/build/luzer/build/luzer/asan_with_fuzzer.so ASAN_OPTIONS=detect_odr_violation=0 gdb --args /home/sergeyb/sources/lua-c-api-tests/build/lua-master/source/lua /home/sergeyb/sources/lua-c-api-tests/tests/lapi/string_format_test.lua -mutate_depth=20 -print_final_stats=1 -print_pcs=1 -reduce_inputs=1 -reload=1 -report_slow_units=5 -runs=${RUNS:-5} -use_value_profile=1 -workers=8 /home/sergeyb/sources/lua-c-api-tests/corpus/string_format
#3953 0x00005555556546cc in __interceptor_sigaltstack ()                                                                                  19:45:48 [3658/8090]
#3954 0x00005555556546cc in __interceptor_sigaltstack ()                                                                                                      
#3955 0x00005555556546cc in __interceptor_sigaltstack ()                                                                                                      
#3956 0x00005555556546cc in __interceptor_sigaltstack ()                                                                                                      
#3957 0x00005555556546cc in __interceptor_sigaltstack ()                                                                                                      
#3958 0x00005555556546cc in __interceptor_sigaltstack ()                                                                                                      
#3959 0x00005555556546cc in __interceptor_sigaltstack ()                                                                                                      
#3960 0x00005555556546cc in __interceptor_sigaltstack ()                                                                                                      
#3961 0x00005555556546cc in __interceptor_sigaltstack ()                                                                                                      
#3962 0x00005555556546cc in __interceptor_sigaltstack ()                                                                                                      
#3963 0x00005555556546cc in __interceptor_sigaltstack ()                                                                                                      
#3964 0x00005555556546cc in __interceptor_sigaltstack ()                                                                                                      
#3965 0x00005555556546cc in __interceptor_sigaltstack ()                                                                                                      
#3966 0x00005555556546cc in __interceptor_sigaltstack ()                                                                                                      
#3967 0x00005555556546cc in __interceptor_sigaltstack ()                                                                                                      
#3968 0x00005555556a8d81 in __sanitizer::SetAlternateSignalStack() ()                                                                                         
#3969 0x00005555556a8eb6 in __sanitizer::InstallDeadlySignalHandlers(void (*)(int, void*, void*)) ()                                           
#3970 0x000055555568be63 in __asan::AsanInitInternal() ()                                                                                                     
#3971 0x000055555568c214 in __asan_init ()                                                                                                                    
#3972 0x00007ffff7fca873 in _dl_init (main_map=0x7ffff7ffe2e0, argc=12, argv=0x7fffffffcfc8, env=0x7fffffffd030) at ./elf/dl-init.c:106                       
#3973 0x00007ffff7fe45a0 in _dl_start_user () from /lib64/ld-linux-x86-64.so.2     

@ligurio
Copy link
Owner Author

ligurio commented Jul 27, 2025

CC=clang CXX=clang++ cmake -S . -B build -DCMAKE_BUILD_TYPE=Debug -DUSE_LUAJIT=ON -DENABLE_LAPI_TESTS=ON -DENABLE_LUA_ASSERT=ON -DENABLE_LUA_APICHECK=ON -DENABLE_ASAN=ON
make bundled-luzer -j10
Starting program: /home/sergeyb/sources/lua-c-api-tests/build/luajit-v2.1/source/src/luajit /home/sergeyb/sources/lua-c-api-tests/tests/lapi/string_rep_test.lua -mutate_depth=20 -print_final_stats=1 -print_pcs=1 -reduce_inputs=1 -reload=1 -report_slow_units=5 -runs=5 -use_value_profile=1 -workers=8
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
munmap_chunk(): invalid pointer
(gdb) bt
#4  0x00007ffff7c288ff in __GI_abort () at ./stdlib/abort.c:79                                                                                                
#5  0x00007ffff7c297b6 in __libc_message_impl (fmt=fmt@entry=0x7ffff7dce8d7 "%s\n") at ../sysdeps/posix/libc_fatal.c:134                             
#6  0x00007ffff7ca8ff5 in malloc_printerr (str=str@entry=0x7ffff7dd1520 "munmap_chunk(): invalid pointer") at ./malloc/malloc.c:5772
#7  0x00007ffff7ca947c in munmap_chunk (p=<optimized out>) at ./malloc/malloc.c:3040                                                                         
#8  0x00007ffff7caddfa in __GI___libc_free (mem=0x7d8ff7860080) at ./malloc/malloc.c:3388                                                                  
#9  0x00007ffff7fcffeb in do_lookup_unique (flags=9, undef_map=0x7d9ff7860680, ref=0x7bfff461ef18, strtab=<optimized out>, sym=<optimized out>, 
    type_class=0, result=0x7fffffffb5a0, map=0x7d9ff7860680, new_hash=1198347278, undef_name=<optimized out>) at ./elf/dl-lookup.c:285                  
#10 do_lookup_x (undef_name=undef_name@entry=0x7bfff4642099 "_ZNSt9money_putIwSt19ostreambuf_iteratorIwSt11char_traitsIwEEE2idE", 
    new_hash=new_hash@entry=1198347278, old_hash=old_hash@entry=0x7fffffffb598, ref=0x7bfff461ef18, result=result@entry=0x7fffffffb5a0,         
    scope=<optimized out>, i=<optimized out>, version=0x7dbff78600b0, flags=9, skip=<optimized out>, type_class=0, undef_map=<optimized out>)
    at ./elf/dl-lookup.c:504                                                                                                                                  
#11 0x00007ffff7fd01fc in _dl_lookup_symbol_x (undef_name=0x7bfff4642099 "_ZNSt9money_putIwSt19ostreambuf_iteratorIwSt11char_traitsIwEEE2idE", 
    undef_map=undef_map@entry=0x7d9ff7860680, ref=ref@entry=0x7fffffffb6c8, symbol_scope=symbol_scope@entry=0x7d9ff7860a20, version=0x7dbff78600b0, 
    type_class=0, flags=9, skip_map=0x0) at ./elf/dl-lookup.c:792
#12 0x00007ffff7fd4ae3 in resolve_map (r_type=1, version=0x7dbff78600b0, ref=0x7fffffffb6c8, scope=<optimized out>, l=<optimized out>)
    at ./elf/dl-reloc.c:190    
#13 elf_machine_rela (skip_ifunc=<optimized out>, reloc_addr_arg=0x7bfff4870260, version=0x7dbff78600b0, sym=0x7bfff461ef18, reloc=0x7bfff468b960, 
    scope=<optimized out>, map=<optimized out>) at ../sysdeps/x86_64/dl-machine.h:285
#14 elf_dynamic_do_Rela (skip_ifunc=<optimized out>, lazy=<optimized out>, nrelative=<optimized out>, relsize=<optimized out>, reladdr=<optimized out>, 
    scope=<optimized out>, map=0x7d9ff7860680) at ./elf/do-rel.h:147
#15 _dl_relocate_object (l=<optimized out>, scope=<optimized out>, reloc_mode=<optimized out>, consider_profiling=<optimized out>, 
    consider_profiling@entry=0) at ./elf/dl-reloc.c:301
#16 0x00007ffff7fd1e0b in _dl_open_relocate_one_object (args=args@entry=0x7fffffffbab0, r=r@entry=0x7ffff7ffe128 <_r_debug>, l=<optimized out>, 
    reloc_mode=reloc_mode@entry=0, relocation_in_progress=relocation_in_progress@entry=0x7fffffffb78f) at ./elf/dl-open.c:511
#17 0x00007ffff7fd2b16 in _dl_open_relocate_one_object (relocation_in_progress=0x7fffffffb78f, reloc_mode=<optimized out>, l=<optimized out>, 
    r=<optimized out>, args=<optimized out>) at ./elf/dl-open.c:478
#18 dl_open_worker_begin (a=a@entry=0x7fffffffbab0) at ./elf/dl-open.c:723
#19 0x00007ffff7fc651c in __GI__dl_catch_exception (exception=exception@entry=0x7fffffffb900, operate=operate@entry=0x7ffff7fd2830 <dl_open_worker_begin>, 
    args=args@entry=0x7fffffffbab0) at ./elf/dl-catch.c:237
#20 0x00007ffff7fd1d20 in dl_open_worker (a=a@entry=0x7fffffffbab0) at ./elf/dl-open.c:803
#21 0x00007ffff7fc651c in __GI__dl_catch_exception (exception=exception@entry=0x7fffffffba90, operate=operate@entry=0x7ffff7fd1ce0 <dl_open_worker>, 
    args=args@entry=0x7fffffffbab0) at ./elf/dl-catch.c:237
#22 0x00007ffff7fd2164 in _dl_open (file=0x7caff78603c8 "/home/sergeyb/sources/lua-c-api-tests/build/luzer/build/luzer/luzer_impl.so", mode=<optimized out>, 
    caller_dlopen=0x55555568dac6 <__interceptor_dlopen+278>, nsid=<optimized out>, argc=11, argv=0x7fffffffcb48, env=0x7fffffffcba8) at ./elf/dl-open.c:905
#23 0x00007ffff7c981a4 in dlopen_doit (a=a@entry=0x7fffffffbd60) at ./dlfcn/dlopen.c:56
#24 0x00007ffff7fc651c in __GI__dl_catch_exception (exception=exception@entry=0x7fffffffbca0, operate=0x7ffff7c98140 <dlopen_doit>, args=0x7fffffffbd60)
    at ./elf/dl-catch.c:237
#25 0x00007ffff7fc6669 in _dl_catch_error (objname=0x7fffffffbd08, errstring=0x7fffffffbd10, mallocedp=0x7fffffffbd07, operate=<optimized out>, 
    args=<optimized out>) at ./elf/dl-catch.c:256
#26 0x00007ffff7c97c83 in _dlerror_run (operate=operate@entry=0x7ffff7c98140 <dlopen_doit>, args=args@entry=0x7fffffffbd60) at ./dlfcn/dlerror.c:138
#27 0x00007ffff7c9825f in dlopen_implementation (dl_caller=<optimized out>, mode=<optimized out>, file=<optimized out>) at ./dlfcn/dlopen.c:71
#28 ___dlopen (file=<optimized out>, mode=<optimized out>) at ./dlfcn/dlopen.c:81
#29 0x000055555568dac6 in __interceptor_dlopen ()
#30 0x00005555558bcc45 in ?? ()
#31 0x00005555558bd5fb in ?? ()
#32 0x00005555557a4b2e in ?? ()
#33 0x00005555558bde75 in ?? ()
#34 0x00005555557a4b2e in ?? ()
#35 0x00005555558bdf47 in ?? ()
#36 0x00005555557a4b2e in ?? ()
#37 0x0000555555747c52 in lua_pcall ()
#38 0x0000555555710604 in ?? ()
#39 0x000055555570f504 in ?? ()
#40 0x00005555557a4b2e in ?? ()
#41 0x0000555555747eb0 in lua_cpcall ()
#42 0x000055555570e751 in main ()
(gdb) 

@ligurio ligurio marked this pull request as draft July 28, 2025 13:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants