Skip to content

Commit 3ae6545

Browse files
committed
monitor-cov: don't keep all corpus entries in memory
1 parent d6d5163 commit 3ae6545

5 files changed

Lines changed: 32 additions & 10 deletions

File tree

Dockerfile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Build with `podman build . -t wasm-fuzzers-wasmfuzz`
2+
FROM ubuntu:24.04
3+
RUN apt-get update && apt-get install -y rustup git clang
4+
RUN rustup toolchain add --no-self-update 1.90
5+
RUN mkdir /wasmfuzz
6+
COPY Cargo.toml Cargo.lock wasmfuzz/
7+
COPY src wasmfuzz/src/
8+
RUN cargo install --locked --no-default-features --path /wasmfuzz && ln -s /root/.cargo/bin/wasmfuzz /usr/bin/
9+
COPY wasm-fuzzers/wasmfuzz.sh /usr/bin/
10+
RUN chmod +x /usr/bin/wasmfuzz.sh
11+
RUN mkdir -p /seeds/ && echo -n "YELLOW SUBMARINE" > /seeds/seed && mkdir -p /corpus/
12+
ENTRYPOINT [ "wasmfuzz.sh" ]

eval/container-runner.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ async def run(self, fuzzer, env=None):
311311
# tuna has ~32gb per 8 cores ( 32GB, 8 cores)
312312
# alfred has 128gb per 8 cores ( 2TB, 128 cores)
313313
# srv-23- has ~32gb per 8 cores (768GB, 192 cores)
314-
fuzzer_cmd += ["--memory", "16g"]
314+
fuzzer_cmd += ["--memory", "8g"]
315315
fuzzer_cmd += ["--network", "none"]
316316
fuzzer_cmd += ["--log-driver", "none"] # afl++ people say that docker's log infra causes performance issues?
317317
if self.core_ids:
@@ -369,8 +369,10 @@ async def run_target(target, fuzzer, config=None, num_cores=1):
369369
config_env = {"FUZZER_CONFIG": None, "FUZZER_CORES": str(num_cores)}
370370
if config is not None:
371371
if isinstance(config, str) and config.startswith("pass-ablation-"):
372-
config_env["FUZZER_PASS_ABLATION"] = config.removeprefix("pass-ablation-")
372+
pass_ = config.removeprefix("pass-ablation-")
373+
config_env["FUZZER_PASS_ABLATION"] = pass_
373374
config = "pass-ablation"
375+
config = dict(name=f"pass-ablation-{pass_}", config=config, args=f"--experiment={config}")
374376
if isinstance(config, str) and fuzzer == "wasmfuzz":
375377
config = dict(name=config, config=config, args=f"--experiment={config}")
376378
if isinstance(config, str):

src/cli/mod.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ pub(crate) fn main() {
401401
let input = std::fs::read(input_path).unwrap();
402402
sess.reset_pass_coverage();
403403
let start = std::time::Instant::now();
404-
let res = sess.run(&input, &mut stats);
404+
let res = sess.run_reusable_fresh(&input, false, &mut stats);
405405
let exec_us = start.elapsed().as_micros();
406406
let is_crash = res.is_crash();
407407
let is_timeout = matches!(res.trap_kind, Some(TrapKind::OutOfFuel(_)));
@@ -856,9 +856,10 @@ pub(crate) fn main() {
856856

857857
for (file_idx, file) in res.files.iter().enumerate() {
858858
if let Some(file_filter) = &file_filter
859-
&& !file.contains(file_filter) {
860-
continue;
861-
}
859+
&& !file.contains(file_filter)
860+
{
861+
continue;
862+
}
862863
let mut blame_lines = res
863864
.map
864865
.iter()

src/cli/monitor_cov.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use crate::{
55
},
66
};
77
use std::{
8+
hash::Hasher,
89
io::Write,
910
path::PathBuf,
1011
time::{Instant, SystemTime},
@@ -111,11 +112,15 @@ pub(crate) fn run(opts: MonitorCovOpts) {
111112
if data.len() > input_size_limit {
112113
continue;
113114
}
114-
if !corpus.insert(data.clone()) {
115+
let data_hash = {
116+
let mut hasher = rustc_hash::FxHasher::with_seed(1234);
117+
hasher.write(&data);
118+
hasher.finish()
119+
};
120+
if !corpus.insert(data_hash) {
115121
continue;
116122
}
117-
118-
let res = sess.run(&data, &mut Stats::default());
123+
let res = sess.run_reusable_fresh(&data, false, &mut Stats::default());
119124
crashes |= res.is_crash();
120125
timeout |= matches!(
121126
res.trap_kind,

src/fuzzer/orc.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -654,7 +654,9 @@ impl Orchestrator {
654654
return None;
655655
}
656656
drop(corp);
657-
let res = self.codecov_sess.run(input, &mut Stats::new());
657+
let res = self
658+
.codecov_sess
659+
.run_reusable_fresh(input, false, &mut Stats::new());
658660
if res.novel_coverage_passes.contains(&"funcs") {
659661
self.last_func_find = Instant::now();
660662
}

0 commit comments

Comments
 (0)