From a1b9866034194a45c8457c52519c19de23306c64 Mon Sep 17 00:00:00 2001 From: Norbert Schneider Date: Mon, 12 Jun 2023 09:44:49 +0200 Subject: [PATCH] Ignore JetBrains classes during instrumentation Some JetBrains products interact badly with Jazzer's agent / instrumentation, e.g. their coverage agent. It's reasonable to ignore all JetBrains classes. --- .../code_intelligence/jazzer/agent/RuntimeInstrumentor.kt | 5 ++++- .../code_intelligence/jazzer/junit/AgentConfigurator.java | 2 +- .../com/code_intelligence/jazzer/utils/ClassNameGlobber.kt | 1 + 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/code_intelligence/jazzer/agent/RuntimeInstrumentor.kt b/src/main/java/com/code_intelligence/jazzer/agent/RuntimeInstrumentor.kt index 8b8dcc994..29756a154 100644 --- a/src/main/java/com/code_intelligence/jazzer/agent/RuntimeInstrumentor.kt +++ b/src/main/java/com/code_intelligence/jazzer/agent/RuntimeInstrumentor.kt @@ -181,7 +181,10 @@ class RuntimeInstrumentor( .acceptClasses(className) .scan() .use { - it.getClassInfo(className).resource.load() + return it.getClassInfo(className)?.resource?.load() ?: run { + Log.warn("Failed to load bytecode of class $className") + return null + } } val (instrumentedBytecode, duration) = measureTimedValue { try { diff --git a/src/main/java/com/code_intelligence/jazzer/junit/AgentConfigurator.java b/src/main/java/com/code_intelligence/jazzer/junit/AgentConfigurator.java index f662eb59c..1f286a317 100644 --- a/src/main/java/com/code_intelligence/jazzer/junit/AgentConfigurator.java +++ b/src/main/java/com/code_intelligence/jazzer/junit/AgentConfigurator.java @@ -65,7 +65,7 @@ private static void applyCommonConfiguration() { // Do not hook common IDE and JUnit classes and their dependencies. System.setProperty("jazzer.custom_hook_excludes", String.join(File.pathSeparator, "com.google.testing.junit.**", "com.intellij.**", - "io.github.classgraph.**", "junit.framework.**", "net.bytebuddy.**", + "org.jetbrains.**", "io.github.classgraph.**", "junit.framework.**", "net.bytebuddy.**", "org.apiguardian.**", "org.assertj.core.**", "org.hamcrest.**", "org.junit.**", "org.opentest4j.**", "org.mockito.**", "org.apache.maven.**", "org.gradle.**")); } diff --git a/src/main/java/com/code_intelligence/jazzer/utils/ClassNameGlobber.kt b/src/main/java/com/code_intelligence/jazzer/utils/ClassNameGlobber.kt index ce45ea18c..c6fa20a72 100644 --- a/src/main/java/com/code_intelligence/jazzer/utils/ClassNameGlobber.kt +++ b/src/main/java/com/code_intelligence/jazzer/utils/ClassNameGlobber.kt @@ -48,6 +48,7 @@ private val BASE_EXCLUDED_CLASS_NAME_GLOBS = listOf( "org.junit.**", // dependency of @FuzzTest "org.mockito.**", // can cause instrumentation cycles "net.bytebuddy.**", // ignore Byte Buddy, though it's probably shaded + "org.jetbrains.**", // ignore JetBrains products (coverage agent) ) + if (IS_BAZEL_COVERAGE_RUN) ADDITIONAL_EXCLUDED_NAME_GLOBS_FOR_BAZEL_COVERAGE else listOf() class ClassNameGlobber(includes: List, excludes: List) {