Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Cyber - Timing Wheel Concurrency bug #15198

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

CHOcho-quan
Copy link

As #15161 stated, there's a concurrency issue under timing wheel.

Considering 3 threads, running the following content

  • Thread I: Starts the timer, and spinning for sometime. Then Stops the timer.
  • Thread II: The timing wheel thread, ticking new tasks
  • Thread III: A task added to TaskManager and running asynchronously

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.

@CLAassistant
Copy link

CLAassistant commented Nov 18, 2023

CLA assistant check
All committers have signed the CLA.

@CHOcho-quan CHOcho-quan changed the title Fix Timing Wheel Concurrency bug Fix Cyber - Timing Wheel Concurrency bug Nov 18, 2023
@daohu527
Copy link
Contributor

daohu527 commented Dec 7, 2023

Will check and feedback soon!

@daohu527 daohu527 self-assigned this Jul 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants