🎲 test: load stdlib in panic-fuzz and add lexer-panic proptest#135
Merged
Conversation
Wires the stdlib `FunctionRegistry` into the panic-fuzz analyser scope and VM globals so randomly-generated programs that reference built-ins (`print`, `len`, etc.) reach the analyser/compiler/VM instead of being rejected up front. Adds a parallel lexer-only proptest seeded with random strings. The expanded fuzzer immediately found `2 ^ i128::MAX` hanging `Number::pow` via `num::pow::Pow` on a multi-billion-bit magnitude. Guarded with an early-return error when the exponent magnitude exceeds 2^32 bits, plus an `expect-error` regression test. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7ee19d660a
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
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.
Summary
tests/proptest/tests/panic.rsnow builds aFunctionRegistry, registers the stdlib, and feeds(name, StaticType)pairs to the analyser scope plus matchingVec<VmValue>(same iteration order so global slots line up) toVm::new. Random programs that reference built-ins (print,len, …) now reach the analyser/compiler/VM instead of being rejected up front. Registry is rebuilt per case (Rc<NativeFunction>is!Send); release-mode cost is negligible — 1M cases in ~66s.tests/proptest/tests/lexer_panic.rsmirrors the panic.rs structure (regression-replay default test +#[ignore]d fuzz test) but generates randomStringinputs. Char strategy is weighted toward lexer-trigger bytes (",\,#,r, digit prefixes/suffixes, operators, comment starts) plus full unicode for multi-byte offset coverage.Number::powexponent guard: first 1M-case run with stdlib loaded shrank to(-2) ^ i128::MAX, which callsnum::pow::Powon a multi-billion-bit magnitude and never returns (the author had flagged this inline inint.rs:120but no guard existed). Now bails withBinaryOperatorError("exponent too large to compute")when the exponent magnitude exceeds 2^32 bits.tests/functional/programs/900_bugs/bug0020_pow_huge_exponent.ndcpins the user-visible error, and the proptest seed inpanic.regressionsguards against the underlying hang.Notes for reviewers
PROPTEST_CASES,MAX_INPUT_LEN).common/module if preferred.🤖 Generated with Claude Code