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 potential data-race in EventLoop #3289

Merged
merged 3 commits into from May 23, 2022
Merged

Fix potential data-race in EventLoop #3289

merged 3 commits into from May 23, 2022

Conversation

qwwdfsad
Copy link
Member

Fixes #3251

@@ -410,6 +415,7 @@ internal abstract class EventLoopImplBase: EventLoopImplPlatform(), Delay {
*/
@JvmField var nanoTime: Long
) : Runnable, Comparable<DelayedTask>, DisposableHandle, ThreadSafeHeapNode {
@Volatile
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without this volatile, removeAtImpl may see an arbitrary value at assert { result.heap === this }, leading to a potential crash.

Copy link
Collaborator

@dkhalanskyjb dkhalanskyjb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couldn't find any negative consequences of the change of order, looks good.

qwwdfsad and others added 2 commits May 20, 2022 16:09
…Test.kt

Co-authored-by: dkhalanskyjb <52952525+dkhalanskyjb@users.noreply.github.com>
Co-authored-by: dkhalanskyjb <52952525+dkhalanskyjb@users.noreply.github.com>
@dkhalanskyjb dkhalanskyjb self-requested a review May 20, 2022 13:14
@qwwdfsad qwwdfsad merged commit 8cdb4d6 into develop May 23, 2022
@qwwdfsad qwwdfsad deleted the eventloop-race branch May 23, 2022 10:20
pablobaxter pushed a commit to pablobaxter/kotlinx.coroutines that referenced this pull request Sep 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants