From e78549cb036dc537a120768864098c5c57b72773 Mon Sep 17 00:00:00 2001 From: aljazkonec1 Date: Wed, 2 Dec 2026 19:47:25 +0100 Subject: [PATCH] fix(RVC4): run the GPU paths in the ASan/UBSan firmware The ASan runtime stops the process when a library is loaded with RTLD_DEEPBIND. The Adreno OpenCL driver loads libllvm-qcom.so this way when it builds a kernel, so on devices with a GPU the rvc4-asan-ubsan firmware aborted in each GPU path (ImageManip GPU backend, GPUStereo, camera undistortion, PointCloud, RGBD). The ASan build exports a dlopen from the executable that removes the flag and calls the next dlopen (the ASan interceptor). Other builds do not change. --- device/rvc4/CMakeLists.txt | 2 ++ device/rvc4/src/utilities/SanitizerDlopen.cpp | 7 +++++++ 2 files changed, 9 insertions(+) create mode 100644 device/rvc4/src/utilities/SanitizerDlopen.cpp diff --git a/device/rvc4/CMakeLists.txt b/device/rvc4/CMakeLists.txt index 8db6bc4880..c164e2c0ac 100644 --- a/device/rvc4/CMakeLists.txt +++ b/device/rvc4/CMakeLists.txt @@ -1001,6 +1001,8 @@ target_sources(${TARGET_DEVICE_EXECUTABLE} if(DEPTHAI_ASAN_UBSAN) target_compile_options(${TARGET_DEVICE_EXECUTABLE} PRIVATE ${DEPTHAI_ASAN_UBSAN_FLAGS}) target_link_options(${TARGET_DEVICE_EXECUTABLE} PRIVATE ${DEPTHAI_ASAN_UBSAN_FLAGS}) + target_sources(${TARGET_DEVICE_EXECUTABLE} PRIVATE src/utilities/SanitizerDlopen.cpp) + target_link_options(${TARGET_DEVICE_EXECUTABLE} PRIVATE "LINKER:--export-dynamic-symbol=dlopen") elseif(DEPTHAI_TSAN) target_compile_options(${TARGET_DEVICE_EXECUTABLE} PRIVATE -fsanitize=thread) target_link_options(${TARGET_DEVICE_EXECUTABLE} PRIVATE -fsanitize=thread) diff --git a/device/rvc4/src/utilities/SanitizerDlopen.cpp b/device/rvc4/src/utilities/SanitizerDlopen.cpp new file mode 100644 index 0000000000..a0547477ae --- /dev/null +++ b/device/rvc4/src/utilities/SanitizerDlopen.cpp @@ -0,0 +1,7 @@ +#include + +extern "C" void* dlopen(const char* filename, int flags) noexcept { + using DlopenFunction = void* (*)(const char*, int); + static const auto nextDlopen = reinterpret_cast(dlsym(RTLD_NEXT, "dlopen")); + return nextDlopen(filename, flags & ~RTLD_DEEPBIND); +}