Repository navigation
Stop the sending thread when the constructor fails after starting it - #17
Merged
Merged
Conversation
…16) A throw in init() after start() reset shared_ but left thread_ joinable, so close() found nothing to close and the destructor called std::terminate. The catch now closes with no wait, which stops and detaches (or joins) the thread exactly as close() does. The test fails each allocation the constructor makes in turn, on the calling thread only, through a counting operator new in the test binary. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Clang's sanitizer runtimes define operator new in a static archive, so a replacement in the test binary fails to link there. Under them the allocation-failure test constructs once without failing anything. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Member
Author
|
Self-review rubric (head 2688720):
Observations:
This self-review was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener). drafted by Claude on behalf of Daniel Stephenson |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
TraceClient::init()'scatch (...)now callsclose(0.0)instead ofshared_.reset(). When anything throws afterstart()has launched the sending thread (the one known case isstd::bad_alloccopying an explicit install ID intoinstallId_), the thread is now stopped and joined or detached exactly asclose()does it. Previouslythread_was left joinable,close()returned early becauseshared_was empty, and~TraceClientcalledstd::terminate, which broke the README's "never throws" promise in its strongest form.operator newwith a thread-local countdown that fails the Nth allocation on the calling thread, once. The new testeveryAllocationTheConstructorMakesMayFailWithoutAbortingmakes each allocation in the constructor fail in turn. Each failure must leave a disabled client (unavailable, no install ID) that can be destroyed safely. The loop ends at the first construction where no allocation was failed, and that client must be enabled and carry the ID. The sending thread and theStubServerthreads are unaffected because the counter is thread-local.Closes #16
Test plan
make test(g++, C++11):55 tests, 0 failed checks(54 before, plus 1)make test STD=c++17andSTD=c++2a(local g++ does not acceptc++20): 55 tests, 0 failed checks. The sizedoperator deleteis defined for C++14+ so that-Wsized-deallocationdoes not fail-Werror.trace_client.hppstashed, the suite aborts withterminate called without an active exception. With the fix restored, it passes.linux(g++/clang++ × c++11/17/20),linux-libcurl,linux-sanitizers(thread; address,undefined),macos,windows(MSVC).operator newin a static archive, and the first CI run failed to link withmultiple definition of operator new. The replacement is therefore compiled out under those sanitizers (SANITIZER_OWNS_NEW). In the two sanitizer jobs the new test constructs a client once and fails no allocation, so the fault injection runs in the other 9 jobs only. TSan could not be linked locally becauselibtsan_preinit.ois missing.Notes
MakefileorCMakeLists.txt.TRACE_CLIENT_CURLon Windows) is waiting on an owner decision between honoring the override and documenting the current behavior, so this cycle did not pick it up.This PR description was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener).
🤖 Generated with Claude Code
drafted by Claude on behalf of Daniel Stephenson