From 9ccf6e358cd512a18ac48aa32468b7efaa2473f7 Mon Sep 17 00:00:00 2001 From: Vsevolod Tolstopyatov Date: Tue, 20 Apr 2021 19:49:09 +0300 Subject: [PATCH] Mention benign data-race in getResult Addresses #2660 --- .../common/src/CancellableContinuationImpl.kt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/kotlinx-coroutines-core/common/src/CancellableContinuationImpl.kt b/kotlinx-coroutines-core/common/src/CancellableContinuationImpl.kt index c310623c5d..f74155eb8f 100644 --- a/kotlinx-coroutines-core/common/src/CancellableContinuationImpl.kt +++ b/kotlinx-coroutines-core/common/src/CancellableContinuationImpl.kt @@ -260,9 +260,13 @@ internal open class CancellableContinuationImpl( // or we got async cancellation from parent. if (trySuspend()) { /* + * Invariant: parentHandle is `null` *only* for reusable continuations. * We were neither resumed nor cancelled, time to suspend. * But first we have to install parent cancellation handle (if we didn't yet), * so CC could be properly resumed on parent cancellation. + * + * This read has benign data-race with write of 'NonDisposableHandle' + * in 'detachChildIfNotReusable'. */ if (parentHandle == null) { installParentHandle()