#920·hyperfine

panic: integer overflow in `--parameter-scan` near i32::MAX

Author: nikolauspschuetzCreated Aug 14, 2026Updated Aug 14, 2026

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.