Skip to content

Commit

Permalink
fix a rare race.
Browse files Browse the repository at this point in the history
  • Loading branch information
aoli-al committed Apr 23, 2024
1 parent 8d9d4d6 commit 4a44ece
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions core/src/main/kotlin/cmu/pasta/sfuzz/core/GlobalContext.kt
Original file line number Diff line number Diff line change
Expand Up @@ -733,19 +733,19 @@ object GlobalContext {
// the thread is waiting for monitor locks.
// We first need to give the thread lock
// and then wakes it up through `notifyAll`.
if (t.blockedBy != null) {
val blockedBy = t.blockedBy
t.blockedBy = null
if (blockedBy != null) {
// FIXME(aoli): relying on type check is not 100% correct,
// because a thread can still be blocked by `condition.wait()`.
if (t.blockedBy is Condition) {
val condition = t.blockedBy as Condition
val lock = lockManager.lockFromCondition(condition)
if (blockedBy is Condition) {
val lock = lockManager.lockFromCondition(blockedBy)
lock.lock()
condition.signalAll()
blockedBy.signalAll()
lock.unlock()
} else {
synchronized(t.blockedBy!!) { (t.blockedBy as Object).notifyAll() }
synchronized(blockedBy) { (blockedBy as Object).notifyAll() }
}
t.blockedBy = null
} else {
t.unblock()
}
Expand Down

0 comments on commit 4a44ece

Please sign in to comment.