From: Ilya Dryomov Date: Wed, 4 Aug 2021 12:58:11 +0000 (+0200) Subject: common/async: drop noexcept on io_context_pool threadfunc X-Git-Tag: v17.1.0~1019^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=b2631ed3e3c4116e141dfb49f62a447e52632687;p=ceph.git common/async: drop noexcept on io_context_pool threadfunc This issue has been addressed in g++ 8: there is no try/catch in execute_native_thread_routine() anymore [1][2] and noexcept ends up having the opposite effect. Whereas without noexcept g++ guarantees that the stack would not be unwound [3], it doesn't make such guarantee for the noexcept case. According to the standard, these cases are distinct and even though both are implementation defined, g++ only defines the former. With noexcept, it unwinds up to the noexcept frame which is not useful at all. (clang unwinds up to and including the noexcept frame and only msvc does the right thing and immediately terminates.) [1] https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=754d67d5ba4a1f9994210d402893a4cf49ce6a71 [2] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55917 [3] https://gcc.gnu.org/onlinedocs/gcc/Exception-handling.html Signed-off-by: Ilya Dryomov --- diff --git a/src/common/async/context_pool.h b/src/common/async/context_pool.h index 992b3eccb0a3..9c6cab7677db 100644 --- a/src/common/async/context_pool.h +++ b/src/common/async/context_pool.h @@ -58,13 +58,8 @@ public: guard.emplace(boost::asio::make_work_guard(ioctx)); ioctx.restart(); for (std::int16_t i = 0; i < threadcnt; ++i) { - // Mark this function as noexcept so any uncaught exceptions - // call terminate at point of throw. Otherwise, under - // libstdc++, they get caught by the thread cancellation - // infrastructure, unwinding the stack and making debugging - // much more difficult. threadvec.emplace_back(make_named_thread("io_context_pool", - [this]() noexcept { + [this]() { ioctx.run(); })); }