From 13909299606a56cdcd009fa9aced5c9464cd8e9e Mon Sep 17 00:00:00 2001 From: Andrey Karpovskii Date: Sat, 19 Feb 2022 00:25:25 +0700 Subject: [PATCH 1/3] End debug session to cleanup --- include/boost/stacktrace/detail/frame_msvc.ipp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/include/boost/stacktrace/detail/frame_msvc.ipp b/include/boost/stacktrace/detail/frame_msvc.ipp index 9b74339..aede3a0 100644 --- a/include/boost/stacktrace/detail/frame_msvc.ipp +++ b/include/boost/stacktrace/detail/frame_msvc.ipp @@ -126,8 +126,8 @@ inline void trim_right_zeroes(std::string& s) { } class debugging_symbols: boost::noncopyable { - static void try_init_com(com_holder< ::IDebugSymbols>& idebug, const com_global_initer& com) BOOST_NOEXCEPT { - com_holder< ::IDebugClient> iclient(com); + static void try_init_com(com_holder< ::IDebugClient>& iclient, com_holder< ::IDebugSymbols>& idebug, + const com_global_initer& com) BOOST_NOEXCEPT { if (S_OK != ::DebugCreate(__uuidof(IDebugClient), iclient.to_void_ptr_ptr())) { return; } @@ -162,12 +162,19 @@ class debugging_symbols: boost::noncopyable { boost::stacktrace::detail::com_global_initer com_; com_holder< ::IDebugSymbols> idebug_; + com_holder< ::IDebugClient> iclient_; public: debugging_symbols() BOOST_NOEXCEPT : com_() , idebug_(com_) + , iclient_(com_) { - try_init_com(idebug_, com_); + try_init_com(iclient_, idebug_, com_); + } + + ~debugging_symbols() BOOST_NOEXCEPT + { + iclient_->EndSession(DEBUG_END_PASSIVE); } #else @@ -181,9 +188,10 @@ public: // or not the member function is inline. static thread_local boost::stacktrace::detail::com_global_initer com; static thread_local com_holder< ::IDebugSymbols> idebug(com); + static thread_local com_holder< ::IDebugClient> iclient(com); if (!idebug.is_inited()) { - try_init_com(idebug, com); + try_init_com(iclient, idebug, com); } return idebug; From ba0d9bce0673ed1a19eb6cfcd4ce17dc0473df87 Mon Sep 17 00:00:00 2001 From: Andrey Karpovskii Date: Sat, 19 Feb 2022 00:39:59 +0700 Subject: [PATCH 2/3] Make sure the client is initialized. --- include/boost/stacktrace/detail/frame_msvc.ipp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/include/boost/stacktrace/detail/frame_msvc.ipp b/include/boost/stacktrace/detail/frame_msvc.ipp index aede3a0..d70d3b8 100644 --- a/include/boost/stacktrace/detail/frame_msvc.ipp +++ b/include/boost/stacktrace/detail/frame_msvc.ipp @@ -174,7 +174,9 @@ public: ~debugging_symbols() BOOST_NOEXCEPT { - iclient_->EndSession(DEBUG_END_PASSIVE); + if (iclient_.is_inited()) { + iclient_->EndSession(DEBUG_END_PASSIVE); + } } #else From 3afae672748242cc8c3da042abf2f7a788ccc834 Mon Sep 17 00:00:00 2001 From: Antony Polukhin Date: Fri, 23 Feb 2024 13:23:41 +0300 Subject: [PATCH 3/3] fix attempt --- include/boost/stacktrace/detail/frame_msvc.ipp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/boost/stacktrace/detail/frame_msvc.ipp b/include/boost/stacktrace/detail/frame_msvc.ipp index 142597f..d52865a 100644 --- a/include/boost/stacktrace/detail/frame_msvc.ipp +++ b/include/boost/stacktrace/detail/frame_msvc.ipp @@ -149,7 +149,7 @@ public: ~debugging_symbols() BOOST_NOEXCEPT { if (iclient_.is_inited()) { - iclient_->EndSession(DEBUG_END_PASSIVE); + iclient_->DetachProcesses(); } } @@ -163,9 +163,9 @@ public: // [class.mfct]: A static local variable or local type in a member function always refers to the same entity, whether // or not the member function is inline. static thread_local com_holder< ::IDebugSymbols> idebug; - static thread_local com_holder< ::IDebugClient> iclient; if (!idebug.is_inited()) { + com_holder< ::IDebugClient> iclient; try_init_com(iclient, idebug); }