]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
cmake/.../FindSanitizers: add check for Sanitizers_FIBER_SUPPPORT
authorSamuel Just <sjust@redhat.com>
Tue, 20 Feb 2024 23:56:26 +0000 (23:56 +0000)
committerSamuel Just <sjust@redhat.com>
Wed, 21 Feb 2024 00:20:23 +0000 (16:20 -0800)
With newer clang and gcc versions (observed on clang-17.0.6 as
well as gcc 12/13), asan is throwing stack-use-after-return
during OSD startup related to usage of seastar::async, which
relies on swapcontext internally.

seastar/src/core/thread.cc supports asan's hooks, but only if
SEASTAR_HAVE_ASAN_FIBER_SUPPORT is set.  seastar's CMakeList.txt
sets it based on Sanitizers_FIBER_SUPPORT, which probably should
be set by the module at src/seastar/cmake/FindSanitizers.cmake,
but that module doesn't seem to be actually invoked anywhere.

Ceph's version of that module (cmake/modules/FindSanitizers.cmake)
does not set Sanitizers_FIBER_SUPPORT.

This commit adds that check as well as the related code snippet.

Fixes: https://tracker.ceph.com/issues/64512
Signed-off-by: Samuel Just <sjust@redhat.com>
cmake/modules/FindSanitizers.cmake
cmake/modules/code_tests/Sanitizers_fiber_test.cc [new file with mode: 0644]

index adafc5ebe3f7a49c7f9b92e6d8db0d3bf8d76ffb..bfb99821a9bd51aa79837e835052d74eed7dcd7b 100644 (file)
@@ -57,6 +57,9 @@ string (REPLACE ";" " " CMAKE_REQUIRED_FLAGS "${Sanitizers_COMPILE_OPTIONS}")
 set(CMAKE_REQUIRED_LIBRARIES ${Sanitizers_COMPILE_OPTIONS})
 check_cxx_source_compiles("int main() {}"
   Sanitizers_ARE_SUPPORTED)
+
+file (READ ${CMAKE_CURRENT_LIST_DIR}/code_tests/Sanitizers_fiber_test.cc _sanitizers_fiber_test_code)
+check_cxx_source_compiles ("${_sanitizers_fiber_test_code}" Sanitizers_FIBER_SUPPORT)
 cmake_pop_check_state()
 
 include(FindPackageHandleStandardArgs)
diff --git a/cmake/modules/code_tests/Sanitizers_fiber_test.cc b/cmake/modules/code_tests/Sanitizers_fiber_test.cc
new file mode 100644 (file)
index 0000000..9df531f
--- /dev/null
@@ -0,0 +1,11 @@
+#include <cstddef>
+
+extern "C" {
+    void __sanitizer_start_switch_fiber(void**, const void*, size_t);
+    void __sanitizer_finish_switch_fiber(void*, const void**, size_t*);
+}
+
+int main() {
+    __sanitizer_start_switch_fiber(nullptr, nullptr, 0);
+    __sanitizer_finish_switch_fiber(nullptr, nullptr, nullptr);
+}