-
Notifications
You must be signed in to change notification settings - Fork 150
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SignedShrinker
calls abs()
on i*::MIN_VALUE
, causing panic
#268
Comments
Nice find! Thanks for the report. This should be fixed in |
Awesome, I'll give it a try. Out of curiosity, did the strategy for choosing the numbers change? I did a |
Yeah, it did. See: #240 The full range of integers is now generated. |
Looks like line 827 of the same file has the same issue. Performing a similar patch locally avoided this bad behavior. diff --git a/src/arbitrary.rs b/src/arbitrary.rs
index 13b5b65..bdd0721 100644
--- a/src/arbitrary.rs
+++ b/src/arbitrary.rs
@@ -824,7 +824,7 @@ macro_rules! signed_shrinker {
impl Iterator for SignedShrinker {
type Item = $ty;
fn next(&mut self) -> Option<$ty> {
- if (self.x - self.i).abs() < self.x.abs() {
+ if self.x == <$ty>::MIN || (self.x - self.i).abs() < self.x.abs() {
let result = Some(self.x - self.i);
self.i = self.i / 2;
result
So I guess a test that actually uses the value is probably a good idea too 😆 |
Consider the following snippet, using quickcheck 1.0.1.
The test is trivial: it just ensures that some future value is smaller than the current.
When running
cargo test
on the snippet, I get (among other stuff)The panic ultimately traces back to this line, where
(-128).abs()
is the root cause. I'm not sure what the intended behavior is here, but a panic is obviously wrong.I'm also not sure why the code is run twice, but I don't think that should be the case either.
The text was updated successfully, but these errors were encountered: