Bound comprehensive diff fuzz inputs#2650
Merged
Merged
Conversation
The comprehensive_diff fuzz target could spend a large amount of time in Myers diff when libFuzzer supplied very large repetitive byte streams. The reported ClusterFuzz artifact is about 800 KiB and took 11.8s locally under cargo-fuzz before the guard. Add a raw input-size budget at the fuzz target boundary before arbitrary decoding or diff computation. The 150 KiB cap keeps the existing 132 KiB ClusterFuzz regression inside the exercised corpus while skipping oversized inputs that mostly attack Myers runtime rather than parser correctness. Co-authored-by: Sebastian Thiel <[email protected]>
Sebastian Thiel (Byron)
force-pushed
the
fix-fuzz-comprehensive-diff
branch
from
June 18, 2026 02:40
d64f47a to
58e7b75
Compare
Sebastian Thiel (Byron)
marked this pull request as ready for review
June 18, 2026 02:40
There was a problem hiding this comment.
Pull request overview
This PR updates the gix-imara-diff comprehensive_diff fuzz target to bound input size and reject inputs that are too large (or can’t be decoded into the structured Input), reducing the risk of libFuzzer timeouts caused by pathological Myers diff cases.
Changes:
- Switch the fuzz target from typed
Inputdecoding to&[u8]input, with explicit decoding viaarbitrary. - Add a maximum input-size guard and return
Corpus::Rejectfor oversized/undecodable inputs. - Return
Corpus::Keepfor in-budget inputs after running the existing comprehensive diff exercise.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Tasks
This section is for Byron only. Models continuing this PR must not add, remove, check, uncheck, rename, or reorder checkboxes here.
Everything below this line was generated by Codex GPT-5.
Created by Codex on behalf of Byron. Byron will review before this is ready to merge.
Reported issue
Summary
The
comprehensive_difffuzz target now guards raw fuzzer input at 512 KiB before arbitrary decoding and diff computation, returningCorpus::Rejectfor oversized or undecodable inputs. In-budget data still usesInput::arbitrary_take_rest, matching the previous typedfuzz_target!(|input: Input| ...)decoding behavior.The reported 800 KiB ClusterFuzz artifact was added as an integration fixture. The existing 132 KiB ClusterFuzz fixture remains inside the budget and continues to exercise the full comprehensive diff path.
Validation
cargo test -p gix-imara-diff fuzzed::timeout_regression --test integration -- --exact --nocapturecargo test -p gix-imara-diff fuzzed::oversized_timeout_regression --test integration -- --exact --nocapturecargo check --manifest-path gix-imara-diff/fuzz/Cargo.toml --bin comprehensive_diffcargo +nightly fuzz run --fuzz-dir gix-imara-diff/fuzz comprehensive_diff ../clusterfuzz-testcase-minimized-gix-imara-diff-comprehensive_diff-5980792761942016 -- -runs=1 -timeout=10cargo test -p gix-imara-diffLocal artifact replay went from 11.8s before the guard to 1ms after the guard.
Commit
d64f47a4020d00c5154ecef23efcbdc0321eae06Bound comprehensive diff fuzz inputs