Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add more fuzz tests #418

Merged
merged 1 commit into from
Aug 27, 2021
Merged

Add more fuzz tests #418

merged 1 commit into from
Aug 27, 2021

Conversation

c410-f3r
Copy link
Contributor

rust-decimal/src/maths.rs

Lines 536 to 542 in 1e35a73

if self >= &Decimal::PI {
// -Sin(x-π)
return match (self - Decimal::PI).checked_sin() {
Some(x) => Some(-x),
None => None,
};
}

#[test]
fn test() {
    use core::str::FromStr;
    let n = crate::Decimal::from_str("-79228162514264.337593543950335").unwrap();
    let _ = n.sin();
}

For some reason the above snippet keeps entering the if self >= &Decimal::PI { branch in an infinite loop overflowing the default stack size.

@paupino
Copy link
Owner

paupino commented Aug 27, 2021

Great find! I'll merge this then look at isolating the failing test case.

@paupino paupino merged commit 193ca72 into paupino:master Aug 27, 2021
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants