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
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmake/BuildLuzer.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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

GIT_PROGRESS TRUE
GIT_SHALLOW FALSE
SOURCE_DIR ${LUZER_DIR}/source
Expand Down
18 changes: 17 additions & 1 deletion tests/lapi/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,22 @@ 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_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

set(LD_PRELOAD_LIBS "${DSO_ASAN_PATH}:${DSO_UBSAN_PATH}")
endif()

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)

"LUA_CPATH=${LUA_CPATH};"
"ASAN_OPTIONS=detect_odr_violation=0;"
"LD_DYNAMIC_WEAK=1;"
"LD_PRELOAD=${LD_PRELOAD_LIBS};"
)

function(create_test)
cmake_parse_arguments(
FUZZ
Expand Down Expand Up @@ -45,7 +61,7 @@ function(create_test)
)
set_tests_properties(${test_name} PROPERTIES
LABELS "lapi"
ENVIRONMENT "LUA_PATH=${LUA_PATH};LUA_CPATH=${LUA_CPATH};ASAN_OPTIONS=detect_odr_violation=0;LD_DYNAMIC_WEAK=1"
ENVIRONMENT "${TEST_ENV}"
DEPENDS ${LUA_EXECUTABLE} ${LUZER_LIBRARY}
)
endfunction()
Expand Down