File tree Expand file tree Collapse file tree 1 file changed +6
-3
lines changed
kotlinx-coroutines-core/common/src/selects Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -413,6 +413,7 @@ internal open class SelectImplementation<R>(
413
413
* or [DisposableHandle] instance when the clause is completed during registration ([inRegistrationPhase] is `false`).
414
414
* Yet, this optimization is omitted for code simplicity.
415
415
*/
416
+ @BenignDataRace // See its cleanup phase for the explanation
416
417
private var internalResult: Any? = NO_RESULT
417
418
418
419
/* *
@@ -626,9 +627,11 @@ internal open class SelectImplementation<R>(
626
627
// try to resume the continuation.
627
628
this .internalResult = internalResult
628
629
if (cont.tryResume(onCancellation)) return TRY_SELECT_SUCCESSFUL
629
- // If the resumption failed, we need to clean
630
- // the [result] field to avoid memory leaks.
631
- this .internalResult = null
630
+ /*
631
+ * If the resumption failed, we need to clean the [result] field to avoid memory leaks.
632
+ * This write is benignly races with the very same write in cancellation invoke() handler
633
+ */
634
+ this .internalResult = NO_RESULT
632
635
return TRY_SELECT_CANCELLED
633
636
}
634
637
}
You can’t perform that action at this time.
0 commit comments