Skip to content

Commit f719449

Browse files
committed
cmake/.../FindSanitizers: add check for Sanitizers_FIBER_SUPPPORT
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 <[email protected]>
1 parent e160811 commit f719449

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

cmake/modules/FindSanitizers.cmake

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ string (REPLACE ";" " " CMAKE_REQUIRED_FLAGS "${Sanitizers_COMPILE_OPTIONS}")
5757
set(CMAKE_REQUIRED_LIBRARIES ${Sanitizers_COMPILE_OPTIONS})
5858
check_cxx_source_compiles("int main() {}"
5959
Sanitizers_ARE_SUPPORTED)
60+
61+
file (READ ${CMAKE_CURRENT_LIST_DIR}/code_tests/Sanitizers_fiber_test.cc _sanitizers_fiber_test_code)
62+
check_cxx_source_compiles ("${_sanitizers_fiber_test_code}" Sanitizers_FIBER_SUPPORT)
6063
cmake_pop_check_state()
6164

6265
include(FindPackageHandleStandardArgs)
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#include <cstddef>
2+
3+
extern "C" {
4+
void __sanitizer_start_switch_fiber(void**, const void*, size_t);
5+
void __sanitizer_finish_switch_fiber(void*, const void**, size_t*);
6+
}
7+
8+
int main() {
9+
__sanitizer_start_switch_fiber(nullptr, nullptr, 0);
10+
__sanitizer_finish_switch_fiber(nullptr, nullptr, nullptr);
11+
}

0 commit comments

Comments
 (0)