You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
A throw in init() after start() leaves thread_ joinable, so the destructor calls std::terminate #16
If anything in TraceClient::init() throws afterstart() has launched the sending thread, the catch (...) resets shared_ but leaves thread_ joinable. close() then returns early because there is no state to close, so ~TraceClient destroys a joinable std::thread, which calls std::terminate. That breaks the "Never throws" promise in the README in its strongest form: the program is aborted.
Where
init() (trace_client.hpp, the else branch after the opt-out checks) calls start(...), which assigns thread_ = std::thread(detail::drain, shared) and then shared_ = shared.
It then runs installId_ = explicitId;, a std::string copy-assignment that can throw std::bad_alloc.
The catch (...) at the end of init() runs shared_.reset(); installId_.clear(); reason_ = REASON_UNAVAILABLE; and does nothing with thread_.
close() returns as soon as it finds no shared state, so the thread is neither joined nor detached, and the sending thread waits forever on a Shared that nothing will close.
The only throwing operation found on this path is the bad_alloc on a copy of at most 255 bytes, so this is unlikely in practice. But it is the one place where the client can take the program down instead of dropping a report.
Possible direction
In the catch, stop the thread the same way close() does before dropping the state. For example, keep a local copy of shared_, set closing under its mutex and notify, then detach() (or join()) thread_. Alternatively, do the fallible install-ID work before start() so that nothing that can throw runs once the thread exists. A test could inject the failure only through allocation hooks, so the fix may have to be checked by review rather than by a test.
Found while reviewing PR #15, which does not touch this path.
Activity
Stop the sending thread when the constructor fails after starting it (#…