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

Open
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
Contributor

@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.

@@ -16,6 +16,13 @@ lapi_tests_make_lua_path(LUA_PATH
${CMAKE_CURRENT_SOURCE_DIR}/?.lua
)

list(APPEND TEST_ENV
"LUA_PATH=${LUA_PATH};"
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor: I suppose there is no need for ; here and below, since it is already the list.

Copy link
Owner Author

Choose a reason for hiding this comment

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

LUA_PATH and LUA_CPATH are not touched in proposed patch, however, I've fixed for LD_PRELOAD_LIBS:

@@ -29,7 +33,7 @@ list(APPEND TEST_ENV
   "LUA_CPATH=${LUA_CPATH};"
   "ASAN_OPTIONS=detect_odr_violation=0;"
   "LD_DYNAMIC_WEAK=1;"
-  "LD_PRELOAD=${LD_PRELOAD_LIBS};"
+  "LD_PRELOAD=${LD_PRELOAD_LIBS}"
 )
 
 function(create_test)

Copy link
Contributor

@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
Contributor

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 <estetus@gmail.com>
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

@@ -16,11 +16,20 @@ lapi_tests_make_lua_path(LUA_PATH
${CMAKE_CURRENT_SOURCE_DIR}/?.lua
)

set(DSO_SANITIZER_PATH "${PROJECT_BINARY_DIR}/luzer/build/luzer")
set(DSO_ASAN_PATH "${DSO_SANITIZER_PATH}/asan_with_fuzzer.so")
Copy link
Contributor

Choose a reason for hiding this comment

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

I would rather name it fuzzer_with_asan.so and fuzzer_with_ubsan.so instead. Feel free to ignore.

Copy link
Owner Author

Choose a reason for hiding this comment

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

This should be addressed here, right? ligurio/luzer#38

set(DSO_ASAN_PATH "${DSO_SANITIZER_PATH}/asan_with_fuzzer.so")
set(DSO_UBSAN_PATH "${DSO_SANITIZER_PATH}/ubsan_with_fuzzer.so")

if(ENABLE_ASAN OR ENABLE_UBSAN)
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe it is better to append the LD_PRELOAD_LIBS env var for each type of sanitizer to avoid loading the UBSan version when only ASan is requested.

Copy link
Owner Author

Choose a reason for hiding this comment

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

Updated:

--- a/tests/lapi/CMakeLists.txt
+++ b/tests/lapi/CMakeLists.txt
@@ -20,8 +20,12 @@ set(DSO_SANITIZER_PATH "${PROJECT_BINARY_DIR}/luzer/build/luzer")
 set(DSO_ASAN_PATH "${DSO_SANITIZER_PATH}/asan_with_fuzzer.so")
 set(DSO_UBSAN_PATH "${DSO_SANITIZER_PATH}/ubsan_with_fuzzer.so")
 
-if(ENABLE_ASAN OR ENABLE_UBSAN)
-  set(LD_PRELOAD_LIBS "${DSO_ASAN_PATH}:${DSO_UBSAN_PATH}")
+if(ENABLE_ASAN)
+  list(APPEND LD_PRELOAD_LIBS ${DSO_ASAN_PATH})
+endif()
+
+if(ENABLE_UBSAN)
+  list(APPEND LD_PRELOAD_LIBS ${DSO_UBSAN_PATH})
 endif()
 
 list(APPEND TEST_ENV

@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     

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