Skip to content

panic: integer overflow in --parameter-scan near i32::MAX #920

Description

@nikolauspschuetz

Summary

--parameter-scan panics with an integer overflow when the range ends at (or one step below) i32::MAX.

Minimal reproduction

hyperfine --parameter-scan x 2147483646 2147483647 'true'
  • Debug/test builds: panics with attempt to add with overflow.
  • Release builds: the addition wraps from i32::MAX to i32::MIN instead of panicking, so the iterator keeps going and hyperfine tries to generate ~4 billion commands (effectively a hang / OOM).

Cause

--parameter-scan parses min/max as i32 (src/command.rs), and the MAX_PARAMETERS (100,000) cap is only enforced at construction via size_hint. A short range positioned near i32::MAX passes that cap, but the iterator's next() in src/parameter/range_step.rs does an unconditional self.state += self.step. On the final element state == i32::MAX, so state + step overflows — panicking in debug and wrapping in release.

Expected

The scan should yield the in-range values and stop, without overflowing, regardless of where the range sits in the i32 domain.

I have a small fix + regression test ready and will open a PR referencing this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions