-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Fix potential data-race in EventLoop #3289
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
Conversation
@@ -410,6 +415,7 @@ internal abstract class EventLoopImplBase: EventLoopImplPlatform(), Delay { | |||
*/ | |||
@JvmField var nanoTime: Long | |||
) : Runnable, Comparable<DelayedTask>, DisposableHandle, ThreadSafeHeapNode { | |||
@Volatile |
There was a problem hiding this comment.
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.
There was a problem hiding this 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.
kotlinx-coroutines-core/jvm/test/internal/ThreadSafeHeapStressTest.kt
Outdated
Show resolved
Hide resolved
…Test.kt Co-authored-by: dkhalanskyjb <[email protected]>
Co-authored-by: dkhalanskyjb <[email protected]>
Fixes #3251