From f719449280d93e96cd03923def9719e0d479e4c1 Mon Sep 17 00:00:00 2001 From: Samuel Just Date: Tue, 20 Feb 2024 23:56:26 +0000 Subject: [PATCH 1/3] 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 --- cmake/modules/FindSanitizers.cmake | 3 +++ cmake/modules/code_tests/Sanitizers_fiber_test.cc | 11 +++++++++++ 2 files changed, 14 insertions(+) create mode 100644 cmake/modules/code_tests/Sanitizers_fiber_test.cc diff --git a/cmake/modules/FindSanitizers.cmake b/cmake/modules/FindSanitizers.cmake index adafc5ebe3f..bfb99821a9b 100644 --- a/cmake/modules/FindSanitizers.cmake +++ b/cmake/modules/FindSanitizers.cmake @@ -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 index 00000000000..9df531f2675 --- /dev/null +++ b/cmake/modules/code_tests/Sanitizers_fiber_test.cc @@ -0,0 +1,11 @@ +#include + +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); +} From 4d430f673a64bbfab0682911de8b22a44fc052bb Mon Sep 17 00:00:00 2001 From: Samuel Just Date: Tue, 20 Feb 2024 16:41:26 -0800 Subject: [PATCH 2/3] crimson/.../shard_services.cc: trivial formatting fix Signed-off-by: Samuel Just --- src/crimson/osd/shard_services.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/crimson/osd/shard_services.cc b/src/crimson/osd/shard_services.cc index 604c045eb9b..e20e310dc2c 100644 --- a/src/crimson/osd/shard_services.cc +++ b/src/crimson/osd/shard_services.cc @@ -809,7 +809,7 @@ seastar::future> OSDSingletonState::build_incremental_map_msg( monc.get_fsid(), osdmap->get_encoding_features()), [this, &first, FNAME, last](unsigned int map_message_max, - auto& m) { + auto &m) { m->cluster_osdmap_trim_lower_bound = superblock.cluster_osdmap_trim_lower_bound; m->newest_map = superblock.get_newest_map(); auto maybe_handle_mapgap = seastar::now(); From e03495dca75be80f642453782ab7793c3c72712e Mon Sep 17 00:00:00 2001 From: Samuel Just Date: Tue, 20 Feb 2024 16:43:16 -0800 Subject: [PATCH 3/3] crimson/.../shard_services.cc: pass by reference from do_with Capturing the value passed by do_with by value causes later captures by reference to be invalid past the lifetime of the lambda frame. Fixes: https://tracker.ceph.com/issues/64513 Signed-off-by: Samuel Just --- src/crimson/osd/shard_services.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/crimson/osd/shard_services.cc b/src/crimson/osd/shard_services.cc index e20e310dc2c..8140ca3f91d 100644 --- a/src/crimson/osd/shard_services.cc +++ b/src/crimson/osd/shard_services.cc @@ -808,7 +808,7 @@ seastar::future> OSDSingletonState::build_incremental_map_msg( crimson::make_message( monc.get_fsid(), osdmap->get_encoding_features()), - [this, &first, FNAME, last](unsigned int map_message_max, + [this, &first, FNAME, last](auto &map_message_max, auto &m) { m->cluster_osdmap_trim_lower_bound = superblock.cluster_osdmap_trim_lower_bound; m->newest_map = superblock.get_newest_map();