diff options
author | Fabian Meumertzheim <meumertzheim@code-intelligence.com> | 2021-07-26 10:55:39 +0200 |
---|---|---|
committer | Fabian Meumertzheim <fabian@meumertzhe.im> | 2021-07-26 12:07:04 +0200 |
commit | 7e57e0e7001587e259aae2ab238794b10ae46333 (patch) | |
tree | 2cf51fc71cf7dc170c867070f16e9c963c68e57a /agent | |
parent | ae8beedfa4db4fd2400d61389e8c4c16954beadc (diff) | |
download | jazzer-api-7e57e0e7001587e259aae2ab238794b10ae46333.tar.gz |
Add process UUID to coverage ID sync file
This should help root cause the rare but persistent coverage ID sync
failures observed on ClusterFuzz.
Diffstat (limited to 'agent')
-rw-r--r-- | agent/src/main/java/com/code_intelligence/jazzer/agent/CoverageIdStrategy.kt | 8 |
1 files changed, 6 insertions, 2 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 16f613eb..fd2a1e7c 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 @@ -19,6 +19,7 @@ import java.nio.channels.FileChannel import java.nio.channels.FileLock import java.nio.file.Path import java.nio.file.StandardOpenOption +import java.util.UUID /** * Indicates a fatal failure to generate synchronized coverage IDs. @@ -90,6 +91,7 @@ private fun FileChannel.append(string: String) { * them across multiple agents. */ internal class SynchronizedCoverageIdStrategy(private val idSyncFile: Path) : CoverageIdStrategy { + val uuid: UUID = UUID.randomUUID() var idFileLock: FileLock? = null var cachedFirstId: Int? = null @@ -125,7 +127,9 @@ internal class SynchronizedCoverageIdStrategy(private val idSyncFile: Path) : Co .filterNot { it.isBlank() } .map { line -> val parts = line.split(':') - check(parts.size == 3) { "Expected ID file line to be of the form '<class name>:<first ID>:<num IDs>', got '$line'" } + check(parts.size == 4) { + "Expected ID file line to be of the form '<class name>:<first ID>:<num IDs>:<uuid>', got '$line'" + } val lineClassName = parts[0] val lineFirstId = parts[1].toInt() check(lineFirstId >= 0) { "Negative first ID in line: $line" } @@ -181,7 +185,7 @@ internal class SynchronizedCoverageIdStrategy(private val idSyncFile: Path) : Co } else { // We are the first to instrument this class and should record the number of IDs in the sync file. check(cachedFirstId != null) - localIdFileLock.channel().append("$cachedClassName:$cachedFirstId:$idCount\n") + localIdFileLock.channel().append("$cachedClassName:$cachedFirstId:$idCount:$uuid\n") localIdFileLock.channel().force(true) } idFileLock = null |