From: Jérémie Galarneau Date: Fri, 17 Jan 2025 21:52:28 +0000 (+0000) Subject: Clean-up: clang-tidy: unhandled exceptions in noexcept functions X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=5aa5b1bed44f649f0e5d956419a291d4ad495a5a;p=lttng-tools.git Clean-up: clang-tidy: unhandled exceptions in noexcept functions While unlikely (would require a corrupted hash table), the iteration adapter's iterator can theoritically throw an exception during the iteration. clang-tidy warns that this is bug prone (bugprone-exception-escape). Change-Id: I89cae7ef662ba6b88c2826a5c8636e0a63fe9117 Signed-off-by: Jérémie Galarneau --- diff --git a/src/bin/lttng-sessiond/ust-registry-session.cpp b/src/bin/lttng-sessiond/ust-registry-session.cpp index a9671dfe2..0e9fd135f 100644 --- a/src/bin/lttng-sessiond/ust-registry-session.cpp +++ b/src/bin/lttng-sessiond/ust-registry-session.cpp @@ -120,13 +120,17 @@ void destroy_channel(lsu::registry_channel *chan, bool notify) noexcept if (chan->_events) { /* Destroy all event associated with this registry. */ - for (auto *event : - lttng::urcu::lfht_iteration_adapter( - *chan->_events->ht)) { - /* Delete the node from the ht and free it. */ - ust_registry_channel_destroy_event(chan, event); + try { + for (auto *event : lttng::urcu::lfht_iteration_adapter< + lsu::registry_event, + decltype(lsu::registry_event::_node), + &lsu::registry_event::_node>(*chan->_events->ht)) { + /* Delete the node from the ht and free it. */ + ust_registry_channel_destroy_event(chan, event); + } + } catch (const lttng::out_of_range& ex) { + ERR_FMT("Corrupted channel events hash table encoutered while destroying channel: {}", + ex.what()); } } @@ -376,16 +380,20 @@ lsu::registry_session::~registry_session() LTTNG_ASSERT(!ret); if (_channels) { - /* Destroy all event associated with this registry. */ - for (auto *chan : - lttng::urcu::lfht_iteration_adapter( - *_channels->ht)) { - /* Delete the node from the ht and free it. */ - ret = cds_lfht_del(_channels.get()->ht, &chan->_node.node); - LTTNG_ASSERT(!ret); - destroy_channel(chan, true); + try { + /* Destroy all event associated with this registry. */ + for (auto *chan : lttng::urcu::lfht_iteration_adapter< + lsu::registry_channel, + decltype(lsu::registry_channel::_node), + &lsu::registry_channel::_node>(*_channels->ht)) { + /* Delete the node from the ht and free it. */ + ret = cds_lfht_del(_channels.get()->ht, &chan->_node.node); + LTTNG_ASSERT(!ret); + destroy_channel(chan, true); + } + } catch (const lttng::out_of_range& ex) { + ERR_FMT("Corrupted channel hash table encountered while destroying session: {}", + ex.what()); } } @@ -412,12 +420,18 @@ lsu::registry_session::~registry_session() /* Destroy the enum hash table */ if (_enums) { - /* Destroy all enum entries associated with this registry. */ - for (auto *reg_enum : - lttng::urcu::lfht_iteration_adapter(*_enums->ht)) { - _destroy_enum(reg_enum); + try { + /* Destroy all enum entries associated with this registry. */ + for (auto *reg_enum : + lttng::urcu::lfht_iteration_adapter( + *_enums->ht)) { + _destroy_enum(reg_enum); + } + } catch (const lttng::out_of_range& ex) { + ERR_FMT("Corrupted enum hash table encountered while destroying session: {}", + ex.what()); } } }