Skip to content

Bound minimal Myers input in the unified diff fuzz target - #3094

Merged
Sebastian Thiel (Byron) merged 1 commit into
mainfrom
uni-diff-printer-fuzz-fix
Oct 23, 2026
Merged

Sebastian Thiel (Byron) merged 1 commit into
mainfrom
uni-diff-printer-fuzz-fix

Conversation

@Byron

@Byron Byron commented Oct 23, 2026 •

Copy link
Copy Markdown
Member

Tasks

This section is for Byron only. Models continuing this PR must not add, remove, check, uncheck, rename, or reorder checkboxes here.

  • refackiew

Everything below this line was generated by Codex.

Created by Codex on behalf of Byron. Byron will review before this is ready to merge.

The supplied ClusterFuzz testcase spends 29.77 seconds in MyersMinimal before unified diff printing starts. This fuzz target now uses the existing comprehensive_diff policy: Histogram and Myers process the complete input, while minimal Myers processes at most 512 tokens per side. The regression completes in about 70 ms in debug mode, and the AddressSanitizer fuzz harness executes the original file in 48 ms.

The library's minimal-diff contract is preserved. Git's xdiff/xdiffi.c at reference checkout commit 6de20f6092 also disables early-abort heuristics for minimal searches. The added fixture and integration test cover decoding, all three algorithms, postprocessing, printing, valid line prefixes, and a three-second budget.

Reported issue

Here is a reproducer for a timeout to fix '/Users/byron/Downloads/clusterfuzz-testcase-minimized-gix-imara-diff-unified_diff_printer-5862399987744768'

Validation

  • GIX_TEST_IGNORE_ARCHIVES=1 cargo test -p gix-imara-diff
  • cargo clippy -p gix-imara-diff --all-targets --all-features -- -D warnings
  • cargo fmt --all -- --check
  • cargo +nightly fuzz run --fuzz-dir gix-imara-diff/fuzz unified_diff_printer <reproducer> -- -runs=1 -timeout=3 (AddressSanitizer)

<!-- agent -->
The reported `unified_diff_printer` ClusterFuzz timeout decodes to
68,956 before tokens and 3,832 after tokens. Replaying it in the
integration test spends 29.77 seconds computing `MyersMinimal`, before
postprocessing or unified diff printing. Histogram and ordinary Myers
finish in under 40 milliseconds each.

Minimal Myers deliberately disables early-abort heuristics. Git's
`xdiff/xdiffi.c` at `6de20f6092` likewise continues its search when
`need_min` is set, and `gix-imara-diff` documents this potentially
expensive behavior. Preserve that contract and apply the existing
`comprehensive_diff` fuzz policy here: retain complete inputs for
Histogram and Myers, then truncate each token sequence to 512 for
minimal Myers.

Assisted-by: GPT 6.1 Sol
Co-authored-by: GPT 6.1 Sol <codex@openai.com>
@Byron
Sebastian Thiel (Byron) marked this pull request as ready for review October 23, 2026 19:25
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
πŸ“ Code Review βœ… Completed 2026-10-23T19:26:11.083083Z ccd1541 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

Codex reacts with πŸ‘€ while any review is running, comments if it has suggestions, and reacts with πŸ‘ once all reviews finish with no findings.

@Byron
Sebastian Thiel (Byron) merged commit 0b9572d into main Oct 23, 2026
33 checks passed
@Byron
Sebastian Thiel (Byron) deleted the uni-diff-printer-fuzz-fix branch October 23, 2026 19:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant