aboutsummaryrefslogtreecommitdiff
path: root/agent
diff options
context:
space:
mode:
authorFabian Meumertzheim <meumertzheim@code-intelligence.com>2021-05-30 12:11:07 +0200
committerFabian Meumertzheim <fabian@meumertzhe.im>2021-05-31 15:19:19 +0200
commit67608415cf72efeebc1130d98aa01754ef0798c3 (patch)
tree94e4adedc15bc0c162f2508d98c7d0a553166c8e /agent
parent338f384ab61578d02bf769f5d0c092e3cca94c36 (diff)
downloadjazzer-api-67608415cf72efeebc1130d98aa01754ef0798c3.tar.gz
Close sync file instead of just releasing the lock
Speculative fix for synchronization failures observed on ClusterFuzz.
Diffstat (limited to 'agent')
-rw-r--r--agent/src/main/java/com/code_intelligence/jazzer/agent/CoverageIdStrategy.kt7
1 files changed, 4 insertions, 3 deletions
diff --git a/agent/src/main/java/com/code_intelligence/jazzer/agent/CoverageIdStrategy.kt b/agent/src/main/java/com/code_intelligence/jazzer/agent/CoverageIdStrategy.kt
index 34afec0a..16f613eb 100644
--- a/agent/src/main/java/com/code_intelligence/jazzer/agent/CoverageIdStrategy.kt
+++ b/agent/src/main/java/com/code_intelligence/jazzer/agent/CoverageIdStrategy.kt
@@ -117,6 +117,7 @@ internal class SynchronizedCoverageIdStrategy(private val idSyncFile: Path) : Co
// Wait until we have obtained the lock on the sync file. We hold the lock from this point until we have
// finished reading and writing (if necessary) to the file.
val localIdFileLock = localIdFile.lock()
+ check(localIdFileLock.isValid && !localIdFileLock.isShared)
// Parse the sync file, which consists of lines of the form
// <class name>:<first ID>:<num IDs>
val idInfo = localIdFileLock.channel().readFully()
@@ -150,12 +151,12 @@ internal class SynchronizedCoverageIdStrategy(private val idSyncFile: Path) : Co
// This class has already been instrumented elsewhere, so we just return the first ID and ID count
// reported from there and release the lock right away. The caller is still expected to call
// commitIdCount.
- localIdFileLock.release()
+ localIdFile.close()
cachedIdCount = idInfoForClass.single().third
idInfoForClass.single().second
}
else -> {
- localIdFileLock.release()
+ localIdFile.close()
System.err.println(idInfo.joinToString("\n") { "${it.first}:${it.second}:${it.third}" })
throw IllegalStateException("Multiple entries for $className in ID file")
}
@@ -190,7 +191,7 @@ internal class SynchronizedCoverageIdStrategy(private val idSyncFile: Path) : Co
} catch (e: Exception) {
throw CoverageIdException(e)
} finally {
- localIdFileLock?.release()
+ localIdFileLock?.channel()?.close()
}
}
}