[Tarantool-patches] [PATCH luajit 4/6] test: more cautious usage of LD_PRELOAD for ASan

Sergey Bronnikov estetus at gmail.com
Tue Mar 26 11:33:30 MSK 2024


From: Sergey Bronnikov <sergeyb at tarantool.org>

This patch adds a comment for clarification about the usage of different
versions of ASan implementations for different compilers. Also, it
replaces ' ' with a ':' as a separator in `LD_PRELOAD` to make it more
robust to the CMake list semantics and removes unnecessary double
quotes.

Needed for tarantool/tarantool#9656

Co-authored-by: Sergey Bronnikov <sergeyb at tarantool.org>
---
 test/LuaJIT-tests/CMakeLists.txt | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/test/LuaJIT-tests/CMakeLists.txt b/test/LuaJIT-tests/CMakeLists.txt
index e8361e97..003f8de6 100644
--- a/test/LuaJIT-tests/CMakeLists.txt
+++ b/test/LuaJIT-tests/CMakeLists.txt
@@ -33,13 +33,19 @@ if(LUAJIT_USE_ASAN)
   # https://github.com/google/sanitizers/issues/934.
   LibRealPath(LIB_STDCPP libstdc++.so)
   # XXX: GCC requires both. Clang requires only libstdc++.
+  # Be aware, ASAN runtime in Clang on Linux was offered only in
+  # the form of a library with differ name from libasan.so (e.g.
+  # libclang_rt.asan-x86_64.a).
+  # See also:
+  # https://github.com/google/sanitizers/wiki/AddressSanitizerAsDso.
   if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
     LibRealPath(LIB_ASAN libasan.so)
-    # XXX: Don't use " " (separator in LD_PRELOAD) in `list()`.
-    # ";" will expand to " " as we want.
-    list(APPEND LUAJIT_TESTS_ENV LD_PRELOAD="${LIB_ASAN};${LIB_STDCPP}")
+    # XXX: The items of the list in LD_PRELOAD can be separated
+    # by spaces or colons, and there is no support for escaping
+    # either separator, see ld.so(8).
+    list(APPEND LUAJIT_TESTS_ENV LD_PRELOAD=${LIB_ASAN}:${LIB_STDCPP})
   else()
-    list(APPEND LUAJIT_TESTS_ENV LD_PRELOAD="${LIB_STDCPP}")
+    list(APPEND LUAJIT_TESTS_ENV LD_PRELOAD=${LIB_STDCPP})
   endif()
 endif()
 
-- 
2.34.1



More information about the Tarantool-patches mailing list