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.
The following ASAN output was generated with the node.peers test, but it's not specific to this test, just seems to be easily reproducible there. Found on Ubuntu 18.04 with Clang, couldn't reproduce on MacOS:
https://gist.github.com/wezrule/17cb9b81ceeaf1a5ccfcec900f666b82
Was a bit of a bugger to locate as anything could have been causing it, but I knew the node destructor was not being called so something must have been holding a
shared_ptr
reference to it, but wasn't sure what. I ended up rolling back commits to find the culprit, which ended up being #1264. In particular (for this example at least) it was this callback:The
worker::stop
function is called but it doesn't remove the callbacks that have been added. So it maintains this node reference. And becauseclass node
has a reference to the worker, they end up keeping each other alive when the test is finished. Passing in aweak_ptr
of the node solves this issue and is what we do in a lot of places in our code but not all. To have a "catch all" I'm removing all the callbacks when the worker is stopped and preventing other ones being added which can happen in other threads.