Fix Cyber - Timing Wheel Concurrency bug #15198
Open
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.
As #15161 stated, there's a concurrency issue under timing wheel.
Considering 3 threads, running the following content
Now Let's say Thread I stops the timer and reset task_ when Thread II has already run line 52 (timing_wheel.cc) & got an instance of the shared pointer. The only shared pointer task is only maintained in Thread II. Let's say somehow the scheduler haven't got enough resource to run Thread III and Thread II finished first. In this case, task_ is released.
If now, Thread III is scheduled by TaskManager and running line 60 (timing_wheel.cc) , since this callback is caught by task->callback, this is a heap-use-after-release problem. This could also be detected by ASAN.