From: Kefu Chai Date: Mon, 29 Jun 2026 01:19:02 +0000 (+0800) Subject: crimson/test: stop the messenger-thrash config on every exit path X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=68ec2a1b3fc20074615aad422b3b5642651b4ee6;p=ceph.git crimson/test: stop the messenger-thrash config on every exit path test_messenger_thrash put sharded_conf().stop() in the success continuation, so an exception from the tests skipped it and left the static sharded holding live instances. its destructor then asserts. a tester hit this when the run went OOM at --memory 256M: ERROR [shard 0:main] test - Test failed: got exception ceph::buffer::v15_2_0::bad_alloc (Bad allocation [buffer:1]) /ceph/src/seastar/include/seastar/core/sharded.hh:573: seastar::sharded::~sharded() [with Service = crimson::common::ConfigProxy]: Assertion `_instances.empty()' failed. terminate called without an active exception run the body in seastar::async and stop the config through seastar::deferred_stop, as crimson/osd/main.cc already does. the guard is constructed only after start() succeeds, and its destructor stops the config on any exit path, so a failing test exits cleanly instead of aborting. Signed-off-by: Kefu Chai --- diff --git a/src/test/crimson/test_messenger_thrash.cc b/src/test/crimson/test_messenger_thrash.cc index ebc4a383ab2..36af35739ce 100644 --- a/src/test/crimson/test_messenger_thrash.cc +++ b/src/test/crimson/test_messenger_thrash.cc @@ -10,7 +10,9 @@ #include #include #include +#include #include +#include #include "common/ceph_argparse.h" #include "messages/MPing.h" @@ -636,31 +638,24 @@ seastar::future do_test(seastar::app_template& app) CEPH_ENTITY_TYPE_CLIENT, &cluster, &conf_file_list); - return crimson::common::sharded_conf().start( - init_params.name, cluster - ).then([] { - return local_conf().start(); - }).then([conf_file_list] { - return local_conf().parse_config_files(conf_file_list); - }).then([&app] { - auto&& config = app.configuration(); - verbose = config["verbose"].as(); - return test_stress(thrash_params_t{8, 32, 50, 120}) - .then([] { - return test_injection(thrash_params_t{16, 32, 50, 120}); - }).then([] { + return seastar::async([init_params, cluster, conf_file_list, &app] { + try { + crimson::common::sharded_conf().start(init_params.name, cluster).get(); + local_conf().start().get(); + auto stop_conf = seastar::deferred_stop(crimson::common::sharded_conf()); + local_conf().parse_config_files(conf_file_list).get(); + verbose = app.configuration()["verbose"].as(); + test_stress(thrash_params_t{8, 32, 50, 120}).get(); + test_injection(thrash_params_t{16, 32, 50, 120}).get(); logger().info("All tests succeeded"); // Seastar has bugs to have events undispatched during shutdown, // which will result in memory leak and thus fail LeakSanitizer. - return seastar::sleep(100ms); - }); - }).then([] { - return crimson::common::sharded_conf().stop(); - }).then([] { - return 0; - }).handle_exception([] (auto eptr) { - logger().error("Test failed: got exception {}", eptr); - return 1; + seastar::sleep(100ms).get(); + return 0; + } catch (...) { + logger().error("Test failed: got exception {}", std::current_exception()); + return 1; + } }); }