Skip to content

Commit e2a6827

Browse files
authored
Fix false positive in WorkQueue.addLast (#2968)
Fixes #2937
1 parent 4b85eb6 commit e2a6827

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

kotlinx-coroutines-debug/src/CoroutinesBlockHoundIntegration.kt

+9
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ public class CoroutinesBlockHoundIntegration : BlockHoundIntegration {
1919
allowServiceLoaderInvocationsOnInit()
2020
allowBlockingCallsInReflectionImpl()
2121
allowBlockingCallsInDebugProbes()
22+
allowBlockingCallsInWorkQueue()
2223
// Stacktrace recovery cache is guarded by lock
2324
allowBlockingCallsInside("kotlinx.coroutines.internal.ExceptionsConstructorKt", "tryCopyException")
2425
/* The predicates that define that BlockHound should only report blocking calls from threads that are part of
@@ -62,6 +63,14 @@ public class CoroutinesBlockHoundIntegration : BlockHoundIntegration {
6263
}
6364
}
6465

66+
/**
67+
* Allow blocking calls inside [kotlinx.coroutines.scheduling.WorkQueue]
68+
*/
69+
private fun BlockHound.Builder.allowBlockingCallsInWorkQueue() {
70+
/** uses [Thread.yield] in a benign way. */
71+
allowBlockingCallsInside("kotlinx.coroutines.scheduling.WorkQueue", "addLast")
72+
}
73+
6574
/**
6675
* Allows blocking inside [kotlinx.coroutines.internal.ThreadSafeHeap].
6776
*/

0 commit comments

Comments
 (0)