Skip to content

Commit 966fa4f

Browse files
committed
fuzz: add size limit to regex building
The fuzzer sometimes runs into situations where it builds regexes that can take a while to execute, such as `\B{10000}`. They fit within the default size limit, but the search times aren't great. But it's not a bug. So try to decrease the size limit a bit to try and prevent timeouts. We might consider trying to optimize cases like `\B{10000}`. A naive optimization would be to remove any redundant conditional epsilon transitions within a single epsilon closure, but that can be tricky to do a priori. The case of `\B{100000}` is probably easy to detect, but they can be arbitrarily complex. Another way to attack this would be to modify, say, the PikeVM to only compute whether a conditional epsilon transition should be followed once per haystack position. Right now, I think it is re-computing them even though it doesn't have to.
1 parent 5d83ee4 commit 966fa4f

File tree

2 files changed

+2
-0
lines changed

2 files changed

+2
-0
lines changed

fuzz/fuzz_targets/fuzz_regex_lite_match.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ fuzz_target!(|case: FuzzCase| {
5555
.dot_matches_new_line(case.dot_matches_new_line)
5656
.swap_greed(case.swap_greed)
5757
.ignore_whitespace(case.ignore_whitespace)
58+
.size_limit(1<<20)
5859
.build() else { return };
5960
re.is_match(case.haystack);
6061
});

fuzz/fuzz_targets/fuzz_regex_match.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ fuzz_target!(|case: FuzzCase| {
5959
.ignore_whitespace(case.ignore_whitespace)
6060
.unicode(case.unicode)
6161
.octal(case.octal)
62+
.size_limit(1<<20)
6263
.build() else { return };
6364
re.is_match(case.haystack);
6465
});

0 commit comments

Comments
 (0)