aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Galenson <jgalenson@google.com>2021-06-21 13:24:06 -0700
committerJoel Galenson <jgalenson@google.com>2021-06-21 13:24:06 -0700
commit577945a102fa064200c7a1068dd8849ae449c517 (patch)
tree7696ff23d6a2a0ae49c20e4bcfae2561022b8406
parent35ec03e672691bf404bdfbb6fd492ace5686bdac (diff)
downloadlibfuzzer-sys-android-s-beta-5.tar.gz
Test: make Change-Id: Id9e8db5b2d19f5e17972a567143f75fe863cc474
-rw-r--r--.cargo_vcs_info.json2
-rw-r--r--Android.bp4
-rw-r--r--CHANGELOG.md13
-rw-r--r--Cargo.toml5
-rw-r--r--Cargo.toml.orig3
-rw-r--r--METADATA8
-rwxr-xr-xci/script.sh2
-rw-r--r--src/lib.rs22
8 files changed, 48 insertions, 11 deletions
diff --git a/.cargo_vcs_info.json b/.cargo_vcs_info.json
index 99e3306..4d6cfd1 100644
--- a/.cargo_vcs_info.json
+++ b/.cargo_vcs_info.json
@@ -1,5 +1,5 @@
{
"git": {
- "sha1": "062f36b424c6dcdbd403c3a5d4384d731c8a3f84"
+ "sha1": "a89115ac1105fa0c7c7d9cb5cdb479af36031aff"
}
}
diff --git a/Android.bp b/Android.bp
index 806370f..1448d8e 100644
--- a/Android.bp
+++ b/Android.bp
@@ -43,6 +43,7 @@ rust_library_rlib {
features: ["arbitrary-derive"],
rustlibs: [
"libarbitrary",
+ "libonce_cell",
],
}
@@ -50,7 +51,8 @@ rust_library_rlib {
// arbitrary-1.0.1 "derive,derive_arbitrary"
// cc-1.0.68
// derive_arbitrary-1.0.1
+// once_cell-1.8.0 "alloc,default,race,std"
// proc-macro2-1.0.27 "default,proc-macro"
// quote-1.0.9 "default,proc-macro"
-// syn-1.0.72 "clone-impls,default,derive,parsing,printing,proc-macro,quote"
+// syn-1.0.73 "clone-impls,default,derive,parsing,printing,proc-macro,quote"
// unicode-xid-0.2.2 "default"
diff --git a/CHANGELOG.md b/CHANGELOG.md
index f0e6039..77be1fd 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -28,6 +28,19 @@ Released YYYY-MM-DD.
--------------------------------------------------------------------------------
+## 0.4.2
+
+Released 2020-05-26.
+
+### Changed
+
+* Improved performance of checking for whether `cargo fuzz` is requesting the
+ `std::fmt::Debug` output of an input or not. This is always false during
+ regular fuzzing, so making this check faster should give slightly better
+ fuzzing throughput.
+
+--------------------------------------------------------------------------------
+
## 0.4.1
Released 2020-05-13.
diff --git a/Cargo.toml b/Cargo.toml
index 6476065..4be2136 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -13,7 +13,7 @@
[package]
edition = "2018"
name = "libfuzzer-sys"
-version = "0.4.1"
+version = "0.4.2"
authors = ["The rust-fuzz Project Developers"]
description = "A wrapper around LLVM's libFuzzer runtime."
readme = "./README.md"
@@ -21,6 +21,9 @@ license = "MIT/Apache-2.0/NCSA"
repository = "https://github.com/rust-fuzz/libfuzzer"
[dependencies.arbitrary]
version = "1"
+
+[dependencies.once_cell]
+version = "1"
[dev-dependencies.flate2]
version = "1.0.20"
diff --git a/Cargo.toml.orig b/Cargo.toml.orig
index adfe66d..72285b9 100644
--- a/Cargo.toml.orig
+++ b/Cargo.toml.orig
@@ -6,10 +6,11 @@ license = "MIT/Apache-2.0/NCSA"
name = "libfuzzer-sys"
readme = "./README.md"
repository = "https://github.com/rust-fuzz/libfuzzer"
-version = "0.4.1"
+version = "0.4.2"
[dependencies]
arbitrary = "1"
+once_cell = "1"
[build-dependencies]
cc = "1.0"
diff --git a/METADATA b/METADATA
index fb5ab95..abca0eb 100644
--- a/METADATA
+++ b/METADATA
@@ -7,13 +7,13 @@ third_party {
}
url {
type: ARCHIVE
- value: "https://static.crates.io/crates/libfuzzer-sys/libfuzzer-sys-0.4.1.crate"
+ value: "https://static.crates.io/crates/libfuzzer-sys/libfuzzer-sys-0.4.2.crate"
}
- version: "0.4.1"
+ version: "0.4.2"
license_type: NOTICE
last_upgrade_date {
year: 2021
- month: 5
- day: 19
+ month: 6
+ day: 21
}
}
diff --git a/ci/script.sh b/ci/script.sh
index b94de7b..91fad80 100755
--- a/ci/script.sh
+++ b/ci/script.sh
@@ -56,3 +56,5 @@ cargo rustc \
-Zsanitizer=address
(! $CARGO_TARGET_DIR/release/example_mutator -runs=10000000)
popd
+
+echo "All good!"
diff --git a/src/lib.rs b/src/lib.rs
index 9262eca..6badc39 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -12,6 +12,7 @@
#![deny(missing_docs, missing_debug_implementations)]
pub use arbitrary;
+use once_cell::sync::OnceCell;
extern "C" {
// We do not actually cross the FFI bound here.
@@ -37,6 +38,9 @@ pub fn test_input_wrap(data: *const u8, size: usize) -> i32 {
}
#[doc(hidden)]
+pub static RUST_LIBFUZZER_DEBUG_PATH: OnceCell<String> = OnceCell::new();
+
+#[doc(hidden)]
#[export_name = "LLVMFuzzerInitialize"]
pub fn initialize(_argc: *const isize, _argv: *const *const *const u8) -> isize {
// Registers a panic hook that aborts the process before unwinding.
@@ -52,6 +56,14 @@ pub fn initialize(_argc: *const isize, _argv: *const *const *const u8) -> isize
default_hook(panic_info);
::std::process::abort();
}));
+
+ // Initialize the `RUST_LIBFUZZER_DEBUG_PATH` cell with the path so it can be
+ // reused with little overhead.
+ if let Ok(path) = std::env::var("RUST_LIBFUZZER_DEBUG_PATH") {
+ RUST_LIBFUZZER_DEBUG_PATH
+ .set(path)
+ .expect("Since this is initialize it is only called once so can never fail");
+ }
0
}
@@ -130,7 +142,9 @@ macro_rules! fuzz_target {
// When `RUST_LIBFUZZER_DEBUG_PATH` is set, write the debug
// formatting of the input to that file. This is only intended for
// `cargo fuzz`'s use!
- if let Ok(path) = std::env::var("RUST_LIBFUZZER_DEBUG_PATH") {
+
+ // `RUST_LIBFUZZER_DEBUG_PATH` is set in initialization.
+ if let Some(path) = $crate::RUST_LIBFUZZER_DEBUG_PATH.get() {
use std::io::Write;
let mut file = std::fs::File::create(path)
.expect("failed to create `RUST_LIBFUZZER_DEBUG_PATH` file");
@@ -151,7 +165,7 @@ macro_rules! fuzz_target {
/// Auto-generated function
#[no_mangle]
pub extern "C" fn rust_fuzzer_test_input(bytes: &[u8]) {
- use libfuzzer_sys::arbitrary::{Arbitrary, Unstructured};
+ use $crate::arbitrary::{Arbitrary, Unstructured};
// Early exit if we don't have enough bytes for the `Arbitrary`
// implementation. This helps the fuzzer avoid exploring all the
@@ -169,7 +183,9 @@ macro_rules! fuzz_target {
// When `RUST_LIBFUZZER_DEBUG_PATH` is set, write the debug
// formatting of the input to that file. This is only intended for
// `cargo fuzz`'s use!
- if let Ok(path) = std::env::var("RUST_LIBFUZZER_DEBUG_PATH") {
+
+ // `RUST_LIBFUZZER_DEBUG_PATH` is set in initialization.
+ if let Some(path) = $crate::RUST_LIBFUZZER_DEBUG_PATH.get() {
use std::io::Write;
let mut file = std::fs::File::create(path)
.expect("failed to create `RUST_LIBFUZZER_DEBUG_PATH` file");