Skip to content

Commit

Permalink
Fix false positive in WorkQueue.addLast (Kotlin#2968)
Browse files Browse the repository at this point in the history
  • Loading branch information
dkhalanskyjb authored and pablobaxter committed Sep 14, 2022
1 parent 3ce65b9 commit f9607c6
Showing 1 changed file with 9 additions and 0 deletions.
Expand Up @@ -19,6 +19,7 @@ public class CoroutinesBlockHoundIntegration : BlockHoundIntegration {
allowServiceLoaderInvocationsOnInit()
allowBlockingCallsInReflectionImpl()
allowBlockingCallsInDebugProbes()
allowBlockingCallsInWorkQueue()
// Stacktrace recovery cache is guarded by lock
allowBlockingCallsInside("kotlinx.coroutines.internal.ExceptionsConstructorKt", "tryCopyException")
/* The predicates that define that BlockHound should only report blocking calls from threads that are part of
Expand Down Expand Up @@ -62,6 +63,14 @@ public class CoroutinesBlockHoundIntegration : BlockHoundIntegration {
}
}

/**
* Allow blocking calls inside [kotlinx.coroutines.scheduling.WorkQueue]
*/
private fun BlockHound.Builder.allowBlockingCallsInWorkQueue() {
/** uses [Thread.yield] in a benign way. */
allowBlockingCallsInside("kotlinx.coroutines.scheduling.WorkQueue", "addLast")
}

/**
* Allows blocking inside [kotlinx.coroutines.internal.ThreadSafeHeap].
*/
Expand Down

0 comments on commit f9607c6

Please sign in to comment.