[C++] Ensure ExecutorServicePtr is not destroyed while the timer object is alive#6226
Merged
merlimat merged 3 commits intoapache:masterfrom Feb 7, 2020
Merged
[C++] Ensure ExecutorServicePtr is not destroyed while the timer object is alive#6226merlimat merged 3 commits intoapache:masterfrom
merlimat merged 3 commits intoapache:masterfrom
Conversation
jiazhai
approved these changes
Feb 5, 2020
ivankelly
approved these changes
Feb 5, 2020
1 task
aahmed-se
pushed a commit
to aahmed-se/pulsar
that referenced
this pull request
Feb 11, 2020
…ct is alive (apache#6226) * [C++] Ensure ExecutorServicePtr is not destroyed while the timer object is alive * Fixed formatting Co-authored-by: Sijie Guo <guosijie@gmail.com>
huangdx0726
pushed a commit
to huangdx0726/pulsar
that referenced
this pull request
Aug 24, 2020
…ct is alive (apache#6226) * [C++] Ensure ExecutorServicePtr is not destroyed while the timer object is alive * Fixed formatting Co-authored-by: Sijie Guo <guosijie@gmail.com>
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.
Motivation
The
ProducerStatsImplandConsumerStatsImplobjects are keeping ashared_ptrto a timer object. While that keeps the timer alive, it does not keep the required event loop object.When the stats objects are destroyed, we cancel the timer, though that will use the already destroyed
ExecutorService. In most cases this will not show any problem, though in others it will cause a segfault.Valgrind output showing the issue:
Modifications
Keep a
shared_ptrtoExecutorServicePtrto ensure the executor service is only destroyed after the timer is cancelled.