-
Notifications
You must be signed in to change notification settings - Fork 149
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
Infinite Repetition/Never Ending Test with f32
and f64
.
#295
Comments
f32
f32
and f64
.
- Added more tests for binary floats. - Added support for mandatory signs in integer writers. - Added support for generic radix floats. - Added extensive unittests for generic radix floats. - Implemented the write float ToLexical API. - Added the WriteFloat trait. Disabled some QuickCheck tests due to the following bug: BurntSushi/quickcheck#295
Also reproduces with Reproducer: use quickcheck::Arbitrary;
i32::MIN.shrink().for_each(|v| println!("{}", v)); Looking at the Line 827 in defde6f
Which results in the endless iteration. I'm honestly surprised this didn't surface any earlier. |
Can you verify that #296 solves your problem? |
Yep, it does. Wonderful, thank you. |
Weirdly, I'm getting another issue with a stack overflow for cases failing with the bit pattern It then attempts to shrink as follows (I believe, this is just the data passed to my test function being printed out as bits): 0b11001110111111111111111111111000
0b11001110111111111111111111111100
0b11001110111111111111111111111110
0b11001110111111111111111111111111
0b11001111000000000000000000000000
0b10000000000000000000000000000000
0b11001110100000000000000000000000
0b11001110110000000000000000000000
0b11001110111000000000000000000000
0b11001110111100000000000000000000
0b11001110111110000000000000000000
0b11001110111111000000000000000000
0b11001110111111100000000000000000
0b11001110111111110000000000000000
0b11001110111111111000000000000000
0b11001110111111111100000000000000
0b11001110111111111110000000000000
0b11001110111111111111000000000000
0b11001110111111111111100000000000
0b11001110111111111111110000000000
0b11001110111111111111111000000000
0b11001110111111111111111100000000
0b11001110111111111111111110000000
0b11001110111111111111111111000000
0b11001110111111111111111111100000 This repeats indefinitely until there's a fatal error due to a stack overflow. I've been using your branch of |
Can you be more specific about what types you use? Also, I this may warrant a new issue, though it definitely looks related. |
I'm using f32, so it should be using a signed shrinker. I'll see if I can create a minimal failing case. |
Looks like I failed to fix the issue properly. The shrinker is bounded but it does yield the original value, which results in an endless recursion as quickcheck executes the test with the exact same value again and again. As I can't reproduce the issue with a |
@neithernut Seems like it has, both #285 and this bug seem to be fixed by the changes. I can't reproduce it exactly with the cases, since running 50 or so repeats never had had those specific bit patterns occur, however, all the failing cases in the shrinker before had a bit pattern of #[cfg(test)]
mod tests {
use quickcheck::quickcheck;
quickcheck! {
fn case_failure(a: f32) -> bool {
let mask = 0b11001110000000000000000000000000;
a.to_bits() & mask != mask
}
}
} The minimum failing case, as expected was
|
I get an infinite loop with the following test case: quickcheck! {
fn something(x: f64) -> bool {
let x = x.abs() % 355.0;
x.cosh().acosh() - x < 1e-10
}
} |
I have trouble reproducing the issue (both on master and with #296). Does this happen with some specific initial values of |
It's random for me :(, may necessitate running the test multiple times. |
To be clear: it does reproduce on master. That much is expected since no fix was merged since the original issue report. However, I dedicated quite a bit of CPU time in an attempt to reproduce the issue with the changes in #296 applied, without any success. So... can you actually reproduce your issue with the fix(es) in #296 or "only" on current master (aka tag 1.0.3 aka defde6f)? |
Yeah, I only reproduced this with 1.0.3. |
It seems this might still be an issue? |
#296 was supposed to fix this, but it was never merged. ...and that's not the only issue still open with an existing fix. |
Related: image-rs/imageproc#522 |
...and switch the 32-bit integer parser to just exhaustive checking. (More on that later.) Why move away from QuickCheck? 1. The maintainer appears to have little interest in actually maintaining it. BurntSushi/quickcheck#315 2. Its API is incredibly inefficient, especially on failure, and it's far too rigid for my needs. For one, I need something looser than `Arbitrary: Clone` so things like `std::io::Error` can be generated more easily. Also, with larger structures, efficiency will directly correlate to faster test runs. Also, I've run into the limitations of not being able to access the underlying random number generator far too many times to count, as I frequently need to generate random values within ranges, among other things. - BurntSushi/quickcheck#279 - BurntSushi/quickcheck#312 - BurntSushi/quickcheck#320 - BurntSushi/quickcheck#267 3. It correctly limits generated `Vec` and `String` length, but it doesn't similarly enforce limits on test length. 4. There's numerous open issues in it that I've addressed, in some cases by better core design. To name a few particularly bad ones: - Misuse of runtime bounds in `Duration` generation, `SystemTime` generation able to panic for unrelated reasons: BurntSushi/quickcheck#321 - Incorrect generation of `SystemTime`: BurntSushi/quickcheck#321 - Unbounded float shrinkers: BurntSushi/quickcheck#295 - Avoiding pointless debug string building: BurntSushi/quickcheck#303 - Signed shrinker shrinks to the most negative value, leading to occasional internal panics: BurntSushi/quickcheck#301 There's still some room for improvement, like switching away from a recursive loop: BurntSushi/quickcheck#285. But, this is good enough for my use cases right now. And this code base is structured such that such a change is *much* easier to do. (It's also considerably simpler.) As for the integer parser change, I found a way to re-structure it so I could perform true exhaustive testing on it. Every code path has every combination of inputs tested, except for memory space as a whole. This gives me enough confidence that I can ditch the randomized property checking for it.
Issue
I've got a test that uses the following structure:
The minimum failing input is:
Adding print debugging with
--nocapture
shows that this value,-2147483600.0
, is called repeatedly, without ever stopping, if the checks pass. The actual implementation uses parsing for an arbitrary radix (using big-integer arithmetic), and a float formatter, but pressing enter in the terminal has printed values rapidly being produced afterwards, showing that the quickcheck is completing each iteration faster than the newline can show (and therefore that the test is stalling out indefinitely due to quickcheck, not the actual test code).A similar result also occurs for
f64
with the following structure:The minimal failing input is:
It's worth noting that these have a practically identical bit pattern, which may help debugging this issue.
The currently rustc/QuickCheck version is:
Debugging/Solution
Is there any way to print the seed so I can more reliably debug these issues? Although the same infinite loop is reproducing on each subsequent run, this is somewhat difficult to debug, given that it uses a random seed and never exits, making it very hard to submit a PR.
The text was updated successfully, but these errors were encountered: