-
Notifications
You must be signed in to change notification settings - Fork 186
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
Overflow when serializing weird values #428
Comments
I'm guessing that there are values that can be constructed via Decimal::deserialize that cannot be constructed via Decimal::from_str, which explains why the test suit didn't pick those up. |
Seems like the internal display implementation can panic this way, which can cause some weird panicked while panicking issues. Line 2056 in 805473b
|
This test makes the fmt::Display call panic as well: #[test]
fn it_can_serialize_weird_values() {
let tests = [
[1u8, 0, 30, 206, 97, 81, 216, 182, 20, 30, 165, 78, 18, 155, 169, 62],
];
for &bytes in &tests {
let dec = Decimal::deserialize(bytes);
let string = format!("{:.9999}", dec);
let dec2 = Decimal::from_str(&string).unwrap();
assert_eq!(dec, dec2);
}
} |
Great write up, thank you. While my immediate thought is to increase the string buffer size I've found that there is often another reason why the additional buffer is used. I'll need to some more investigation to see what is triggering this - hopefully later this week. |
The following code fails as well: let num = Decimal::from_str("1.2").unwrap();
println!("Decimal value:");
println!("{:.32}", num);
Not sure if this is expected. |
Wow... Panicking inside the Display implementation was unexpected |
This issue actually has two underlying problems present which should get fixed in #433 (once complete):
|
While doing some fuzzing, I found this weird value that fails to serialize.
Fails with:
The text was updated successfully, but these errors were encountered: