Skip to content

fuzz: add dedicated number boundary fuzzer#160

Merged
membphis merged 4 commits into
mainfrom
worktree-fuzz-numbers-153
Jun 2, 2026
Merged

fuzz: add dedicated number boundary fuzzer#160
membphis merged 4 commits into
mainfrom
worktree-fuzz-numbers-153

Conversation

@membphis
Copy link
Copy Markdown
Collaborator

@membphis membphis commented Jun 2, 2026

Summary

Add a dedicated fuzz target (fuzz_numbers) that generates numbers biased toward parsing boundaries to stress-test the number decoder.

Closes #153

Changes

  • fuzz/fuzz_targets/fuzz_numbers.rs: New fuzz target using arbitrary crate to generate structured number components with ~70% boundary bias
  • fuzz/corpus/fuzz_numbers/: Seeded with JSON Test Suite i_number_* cases
  • fuzz.yml: Added fuzz_numbers to timed fuzzing schedule

Number Patterns Generated

  • Exponent boundaries: 1e308, 1e-308, 1e309 (overflow), 1e-324 (underflow)
  • Integer boundaries: i64::MAX, i64::MIN, u64::MAX, overflow variants
  • Leading zeros: 00, 01, -00 (RFC 8259 violations)
  • Sign variations: -0, +1 (invalid), --1 (invalid)
  • Decimal precision: 17+ digit mantissas
  • Whitespace adjacency: numbers with surrounding whitespace

Validation

  • EAGER mode rejects RFC 8259 violations at parse time
  • LAZY mode defers validation to extraction time
  • Cross-validates accept/reject behavior against serde_json
  • Verifies extracted values match serde_json decoding

membphis added 3 commits June 2, 2026 12:59
Implements structured number fuzzing using the arbitrary crate to test RFC 8259 compliance and numeric decode correctness.

Key features:
- Boundary-biased generation (70%): exponent limits (1e308, 1e-308, 1e309, 1e-324), integer boundaries (i64::MAX±1, u64::MAX±1), leading zeros (00, 01), invalid signs (+1, --1)
- Random generation (30%): arbitrary sign/integer/fraction/exponent combinations
- Whitespace variation: tests numbers with various surrounding whitespace
- Dual-mode validation: EAGER mode must reject RFC 8259 violations, LAZY mode defers to access time
- Cross-validation: compares accept/reject decisions with serde_json
- Extraction verification: validates decoded i64/f64 values match expected results

Test vectors include:
- Exponent boundaries: 1e308, 1e-308, 1e309 (overflow), 1e-324 (underflow)
- Integer boundaries: i64::MAX, i64::MAX+1, i64::MIN, i64::MIN-1, u64::MAX, u64::MAX+1
- Leading zeros: 00, 01, -00 (invalid RFC 8259)
- Invalid signs: +1, --1
- Decimal precision: up to 20-digit mantissas

The fuzzer wraps generated numbers in JSON arrays [number] and tests both parse-time validation (EAGER vs LAZY) and access-time decode via qjson_get_i64/qjson_get_f64 FFI calls.
Add 10 i_number_*.json files from JSONTestSuite as initial corpus:
- Edge cases for huge exponents (positive and negative)
- Overflow and underflow scenarios
- Very large integers beyond standard limits

These seed inputs target number parsing edge cases in the fuzz_numbers harness.
Add fuzz_numbers target to the weekly fuzzing workflow. The target exercises number parsing edge cases including large exponents, precision boundaries, and RFC 8259 compliance.
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 2, 2026

Warning

Review limit reached

@membphis, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 20 minutes and 39 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 8cb70af7-5d04-4d50-9e4a-0d5e81c9cb18

📥 Commits

Reviewing files that changed from the base of the PR and between ce8642b and 3633fe8.

⛔ Files ignored due to path filters (1)
  • fuzz/Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (13)
  • .github/workflows/fuzz.yml
  • fuzz/Cargo.toml
  • fuzz/corpus/fuzz_numbers/i_number_double_huge_neg_exp.json
  • fuzz/corpus/fuzz_numbers/i_number_huge_exp.json
  • fuzz/corpus/fuzz_numbers/i_number_neg_int_huge_exp.json
  • fuzz/corpus/fuzz_numbers/i_number_pos_double_huge_exp.json
  • fuzz/corpus/fuzz_numbers/i_number_real_neg_overflow.json
  • fuzz/corpus/fuzz_numbers/i_number_real_pos_overflow.json
  • fuzz/corpus/fuzz_numbers/i_number_real_underflow.json
  • fuzz/corpus/fuzz_numbers/i_number_too_big_neg_int.json
  • fuzz/corpus/fuzz_numbers/i_number_too_big_pos_int.json
  • fuzz/corpus/fuzz_numbers/i_number_very_big_negative_int.json
  • fuzz/fuzz_targets/fuzz_numbers.rs
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch worktree-fuzz-numbers-153

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 1.05.

Benchmark suite Current: 3633fe8 Previous: ce8642b Ratio
parse_lazy/parse/deep_nesting 2841 ns/iter (± 11) 2488 ns/iter (± 14) 1.14

This comment was automatically generated by workflow using github-action-benchmark.

@membphis membphis marked this pull request as ready for review June 2, 2026 05:05
@membphis membphis merged commit 8e1b394 into main Jun 2, 2026
16 checks passed
@membphis membphis deleted the worktree-fuzz-numbers-153 branch June 2, 2026 05:08
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.

fuzz: add dedicated number boundary fuzzer

1 participant