Avoid resetting unique_ptr not being the owner of the pointed element#1086
Closed
whoan wants to merge 1 commit intomicrosoft:masterfrom
Closed
Avoid resetting unique_ptr not being the owner of the pointed element#1086whoan wants to merge 1 commit intomicrosoft:masterfrom
whoan wants to merge 1 commit intomicrosoft:masterfrom
Conversation
Member
|
Hmmm I don't think this is the case because it looks like the thread is joined before the call to reset, not after. This change doesn't seem to do anything other than consume more memory? |
Contributor
Author
|
@BillyONeal I have seen some double deletions of the unique_ptr but I wonder if it was before PR #1080 was joined. I will try to reproduce later and will let you know. |
Member
|
OK, feel free to reopen if you can run it down. |
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.
This PR is to avoid resetting a unique_ptr in a new thread as it (the new thread) is not the owner of the pointed element, and
unique_ptris not thread safe, so some obscure errors could happen. Consider this snippet for testing purposes:Both
unique.reset();might be called at the same time causing UB. I think something similar is happening inshutdown_wspp_impl.What is the price of stop calling
m_client.reset();as suggested in this PR?This might be related to issue #32