Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In jazzer,when i run "bazel coverage ",throws ClassNotFoundException. #84

Open
Xingyunting opened this issue Sep 1, 2022 · 1 comment

Comments

@Xingyunting
Copy link

I want to use build coverage in jazzer.When I run “bazel run //examples:ExampleFuzzerWithUBSan”,got success.But when I run “bazel coverage //examples:ExampleFuzzerWithUBSan”,the testlog print out:

exec ${PAGER:-/usr/bin/less} "$0" || exit 1
Executing tests from //examples:ExampleFuzzerWithUBSan
-----------------------------------------------------------------------------
singlejar_local: ./src/tools/singlejar/mapped_file_posix.inc:42: open /private/var/tmp/_bazel_xyt/b041260c26ede733a242223b95e6c3b7/sandbox/darwin-sandbox/1117/execroot/jazzer/bazel-out/darwin_arm64-opt/bin/examples/ExampleFuzzerWithUBSan.runfiles/fmeum_rules_jni/jni/tools/libjvm_stub/coverage/CoverageAgent.jar:: No such file or directory
singlejar_local: src/tools/singlejar/input_jar.cc:23: Cannot open input jar /private/var/tmp/_bazel_xyt/b041260c26ede733a242223b95e6c3b7/sandbox/darwin-sandbox/1117/execroot/jazzer/bazel-out/darwin_arm64-opt/bin/examples/ExampleFuzzerWithUBSan.runfiles/fmeum_rules_jni/jni/tools/libjvm_stub/coverage/CoverageAgent.jar: No such file or directory
OpenJDK 64-Bit Server VM warning: CriticalJNINatives specified, but not supported in this VM
INFO: Loaded 147 hooks from com.code_intelligence.jazzer.runtime.TraceCmpHooks
INFO: Loaded 4 hooks from com.code_intelligence.jazzer.runtime.TraceDivHooks
INFO: Loaded 2 hooks from com.code_intelligence.jazzer.runtime.TraceIndirHooks
INFO: Loaded 4 hooks from com.code_intelligence.jazzer.runtime.NativeLibHooks
INFO: Loaded 8 hooks from com.code_intelligence.jazzer.sanitizers.Deserialization
INFO: Loaded 5 hooks from com.code_intelligence.jazzer.sanitizers.ExpressionLanguageInjection
INFO: Loaded 70 hooks from com.code_intelligence.jazzer.sanitizers.LdapInjection
INFO: Loaded 50 hooks from com.code_intelligence.jazzer.sanitizers.NamingContextLookup
INFO: Loaded 1 hooks from com.code_intelligence.jazzer.sanitizers.OsCommandInjection
INFO: Loaded 48 hooks from com.code_intelligence.jazzer.sanitizers.ReflectiveCall
INFO: Loaded 8 hooks from com.code_intelligence.jazzer.sanitizers.RegexInjection
[rules_jni] Failed to collect coverage for native libraries:
java.lang.ClassNotFoundException: javax/com/github/fmeum/rules_jni/gen/jazzer_driver_2690633507
	at java.lang.Class.forName0(Native Method)
	at java.lang.Class.forName(Class.java:264)
	at com.code_intelligence.jazzer.bootstrap.com.github.fmeum.rules_jni.CoverageHelper.callHelperMethod(CoverageHelper.java:160)
	at com.code_intelligence.jazzer.bootstrap.com.github.fmeum.rules_jni.CoverageHelper.initCoverage(CoverageHelper.java:39)
	at com.code_intelligence.jazzer.bootstrap.com.github.fmeum.rules_jni.RulesJni.loadLibrary(RulesJni.java:121)
	at com.code_intelligence.jazzer.bootstrap.com.github.fmeum.rules_jni.RulesJni.loadLibrary(RulesJni.java:93)
	at com.code_intelligence.jazzer.runtime.TraceDataFlowNativeCallbacks.<clinit>(TraceDataFlowNativeCallbacks.java:26)
	at java.lang.Class.forName0(Native Method)
	at java.lang.Class.forName(Class.java:264)
	at com.code_intelligence.jazzer.api.Jazzer.<clinit>(Jazzer.java:49)
	at com.code_intelligence.jazzer.sanitizers.RegexRoadblocks.<clinit>(RegexRoadblocks.java:72)
	at java.lang.Class.forName0(Native Method)
	at java.lang.Class.forName(Class.java:348)
	at com.code_intelligence.jazzer.instrumentor.Hooks$Companion$HooksLoader.loadHooks(Hooks.kt:85)
	at com.code_intelligence.jazzer.instrumentor.Hooks$Companion$HooksLoader.load(Hooks.kt:67)
	at com.code_intelligence.jazzer.instrumentor.Hooks$Companion.loadHooks(Hooks.kt:61)
	at com.code_intelligence.jazzer.agent.Agent.install(Agent.kt:102)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at com.code_intelligence.jazzer.agent.AgentInstaller.install(AgentInstaller.java:59)
	at com.code_intelligence.jazzer.driver.FuzzTargetRunner.<clinit>(FuzzTargetRunner.java:55)
	at com.code_intelligence.jazzer.driver.Driver.start(Driver.java:88)
Did expect a crash, but Jazzer exited with exit code 1
--
Coverage runner: Not collecting coverage for failed test.
The following commands failed with status 1
/private/var/tmp/_bazel_xyt/b041260c26ede733a242223b95e6c3b7/sandbox/darwin-sandbox/1117/execroot/jazzer/bazel-out/darwin_arm64-opt/bin/examples/ExampleFuzzerWithUBSan.runfiles/jazzer/examples/ExampleFuzzerWithUBSan driver/jazzer_driver_ubsan agent/jazzer_api_deploy.jar examples/ExampleFuzzerWithUBSan_target_deploy.jar  True False True  --jvm_args=-Djazzer.native_lib=native_ubsan

In jazzer/bazel-out/darwin_arm64-opt/bin/examples/ExampleFuzzerWithASan.runfiles/fmeum_rules_jni/jni/tools/libjvm_stub/coverage/ ,just have a coverage_deploy.jar,so it build failed.

@fmeum
Copy link
Owner

fmeum commented Oct 15, 2022

Jazzer is unfortunately a bit of a tricky case as it contains two shaded copies of rules_jni and appends a jar using it to the bootstrap classpath. We are currently working on simplifying the architecture further. When that is done, I will look into whether this use case is still broken.

If what you are really interested in is fuzz test coverage, I would instead guide you to use https://github.com/bazelbuild/rules_fuzzing, to which I intend to add Java coverage soon after the Jazzer refactoring is done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants