Skip to content

Commit b4fa647

Browse files
authored
Cap iterations of component_api fuzzer (#12103)
This timed out over the weekend on OSS-Fuzz and running locally it just runs quite a lot of iterations of the test case in question. There's no need to run so much in one fuzz test case so cap the total number of iterations at a constant to avoid timing out.
1 parent a7edc9b commit b4fa647

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

crates/fuzzing/src/oracles/component_api.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ const MIN_LIST_LENGTH: u32 = 0;
2727
/// Maximum length of an arbitrary list value generated for a test case
2828
const MAX_LIST_LENGTH: u32 = 10;
2929

30+
/// Maximum number of invocations of one fuzz case.
31+
const MAX_ITERS: usize = 1_000;
32+
3033
/// Generate an arbitrary instance of the specified type.
3134
fn arbitrary_val(ty: &component::Type, input: &mut Unstructured) -> arbitrary::Result<Val> {
3235
use component::Type;
@@ -263,7 +266,8 @@ where
263266
.get_typed_func::<P, R>(&mut store, EXPORT_FUNCTION)
264267
.unwrap();
265268

266-
while input.arbitrary()? {
269+
let mut iters = 0..MAX_ITERS;
270+
while iters.next().is_some() && input.arbitrary()? {
267271
let params = input.arbitrary::<P>()?;
268272
let result = input.arbitrary::<R>()?;
269273
*store.data_mut() = Box::new((params.clone(), result.clone()));
@@ -352,7 +356,8 @@ pub fn dynamic_component_api_target(input: &mut arbitrary::Unstructured) -> arbi
352356
let func = instance.get_func(&mut store, EXPORT_FUNCTION).unwrap();
353357
let ty = func.ty(&store);
354358

355-
while input.arbitrary()? {
359+
let mut iters = 0..MAX_ITERS;
360+
while iters.next().is_some() && input.arbitrary()? {
356361
let params = ty
357362
.params()
358363
.map(|(_, ty)| arbitrary_val(&ty, input))

0 commit comments

Comments
 (0)