Skip to content
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

Initial attempt at roundtrip fuzzing #111

Closed
wants to merge 4 commits into from

Conversation

Shnatsel
Copy link

This found a counter-example very quickly, but I suspect I'm just doing something wrong:

thread '<unnamed>' panicked at 'assertion failed: `float_eq!(left, right, rmax <= t)`
        left: `-6308.5176`,
       right: `NaN`,
    abs_diff: `NaN`,
   ulps_diff: `None`,
    [rmax] t: `630.85175`', fuzz_targets/roundtrip.rs:44:9

@Shnatsel Shnatsel mentioned this pull request Jan 30, 2023
@Shnatsel
Copy link
Author

You can run this with cargo +nightly fuzz run roundtrip

@HEnquist
Copy link
Contributor

Roundtripping won't work when there are NaNs or infinity in the input data! If there is a NaN in the input, then every math operation involving that element will return NaN. Which basically means the entire output is just NaNs.

@Shnatsel
Copy link
Author

Shnatsel commented Feb 1, 2023

I've added code that strips NaN and inf values from the input. The fuzzer still finds counter-examples very quickly.

@Shnatsel
Copy link
Author

Shnatsel commented Feb 1, 2023

Okay, so either I'm doing something very wrong, or this is a bug:

thread '<unnamed>' panicked at 'assertion failed: `float_eq!(left, right, rmax <= t)`
        left: `-6328.63`,
       right: `2209923.3`,
    abs_diff: `2216252.0`,
   ulps_diff: `None`,
    [rmax] t: `2209923.3`', fuzz_targets/roundtrip.rs:51:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Input triggering it, text form:

	[
	    -6328.63,
	    1.9044803e-32,
	    3310146.5,
	    -2.6888979e38,
	    3325951.8,
	    -1.0587911e-22,
	]

Binary form (gzipped):

crash-fcf909c931e12fec5df36a5e4d7f5a026663e4d6.gz

Reproduce with:

cargo fuzz run -O roundtrip crash-fcf909c931e12fec5df36a5e4d7f5a026663e4d6

@HEnquist
Copy link
Contributor

HEnquist commented Feb 1, 2023

That is just unavoidable numerical noise. With f32 you have roughly 8 significant digits. The values here:
-6328.63, 1.9044803e-32, 3310146.5, -2.6888979e38, 3325951.8, -1.0587911e-22
have a range of 10^70! Since the largest term is at 10^38, you can get rounding errors up to 10^30.
I don't think there is any point in testing with such a large range of values, the results will mostly be noise.

@Shnatsel
Copy link
Author

Shnatsel commented Feb 1, 2023

All right, since roundtripping is harder than I thought it would be, I'll shelve it for now and focus on more traditional fuzzing that looks for memory errors.

Once the template is in place, someone with FFT domain knowledge can expand on that and implement comparisons against a reference implementation, roundtrips, etc.

@Shnatsel Shnatsel closed this Feb 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants