From d555d6122d1d1a354c45361d029571413beca8ef Mon Sep 17 00:00:00 2001 From: Andrew Gallant Date: Wed, 24 May 2023 19:16:23 -0400 Subject: [PATCH] fuzz: don't run on big haystacks We keep beating back the OSS-fuzz timeouts. It keeps finding bigger and bigger haystacks with even smallish regexes that have Unicode word boundaries in them. This results in using the PikeVM which is just slow. There's really nothing to be done other than to tell the fuzzer: "this is OK." --- fuzz/fuzz_targets/fuzz_regex_match.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/fuzz/fuzz_targets/fuzz_regex_match.rs b/fuzz/fuzz_targets/fuzz_regex_match.rs index 285ae352d..8b3453934 100644 --- a/fuzz/fuzz_targets/fuzz_regex_match.rs +++ b/fuzz/fuzz_targets/fuzz_regex_match.rs @@ -14,6 +14,15 @@ fuzz_target!(|data: &[u8]| { let char_index = data.char_indices().nth(split_off_point); if let Some((char_index, _)) = char_index { let (pattern, input) = data.split_at(char_index); + // If the haystack is big, don't use it. The issue is that + // the fuzzer is compiled with sanitizer options and it makes + // everything pretty slow. This was put in here as a result of + // getting timeout errors from OSS-fuzz. There's really nothing to + // be done about them. Unicode word boundaries in the PikeVM are + // slow. It is what it is. + if input.len() >= 8 * (1 << 10) { + return; + } let result = regex::RegexBuilder::new(pattern).size_limit(1 << 18).build(); if let Ok(re) = result {