Fix native library handling (#195)
* Correctly escape native library path separator
This should have been changed when Jazzer was updated past
https://github.com/CodeIntelligenceTesting/jazzer/commit/24069c388579f54ec9872e61efa44f5e6065f838
but was missed due to missing test coverage for the case of multiple
native libraries.
When Bazel 5 was released today, the use of transitions coupled with
https://github.com/bazelbuild/bazel/commit/20061f8fb7ed95924c6cdbaaaf3d06a64edf974e
caused the NativeFuzzTest example to suddenly have two native library
dependencies, which triggered the dormant bug.
* Skip non-dynamic libraries for java.library.path
transitive_native_libraries can contain LibraryToLink instances for
static libraries and object files, which do not have to be added to the
java.library.path. Prevent analysis time failures by skipping them.
diff --git a/fuzzing/private/java_utils.bzl b/fuzzing/private/java_utils.bzl
index 0e1aed7..70c4e24 100644
--- a/fuzzing/private/java_utils.bzl
+++ b/fuzzing/private/java_utils.bzl
@@ -132,7 +132,10 @@
agent = runfile_path(ctx, ctx.file.agent),
deploy_jar = runfile_path(ctx, ctx.file.target_deploy_jar),
driver = runfile_path(ctx, driver),
- native_dirs = ":".join(native_dirs),
+ # Jazzer requires the path separator to be escaped in --jvm_args.
+ # See:
+ # https://github.com/CodeIntelligenceTesting/jazzer#passing-jvm-arguments
+ native_dirs = "\\:".join(native_dirs),
sanitizer_options = runfile_path(ctx, ctx.file.sanitizer_options),
)
ctx.actions.write(script, script_content, is_executable = True)
@@ -178,7 +181,11 @@
# the JavaInfo of the target includes information about all transitive
# native library dependencies.
native_libraries_list = target_java_info.transitive_native_libraries.to_list()
- return [lib.dynamic_library for lib in native_libraries_list]
+ return [
+ lib.dynamic_library
+ for lib in native_libraries_list
+ if lib.dynamic_library != None
+ ]
else:
# If precise information about transitive native libraries is not
# available, fall back to an overapproximation that includes all