-
Notifications
You must be signed in to change notification settings - Fork 5
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
[BUG] #7
Comments
Let me quickly check: this is specifically an issue with a number with a large number of zeros and not a large number of digits in general. Can you tell me how this is passed to minimal-lexical? Is it: Specifically, the issue is here: Lines 153 to 158 in e997c46
Which can only fail if |
This is likely a bug in minimal-lexical, since our documentation clearly states we should not have leading zeros only in the integer component. |
I got the same panic when using nom 7.0.0 and this input: |
This bug unfortunately prevents me from fuzzing my code (libfuzzer always converges to it, damn it's good! 😂 ) I can add a test to the crate's test suite to reproduce (over e997c46): diff --git a/tests/parse_tests.rs b/tests/parse_tests.rs
index 48856fd..91d24ab 100644
--- a/tests/parse_tests.rs
+++ b/tests/parse_tests.rs
@@ -51,6 +51,8 @@ fn parse_f32_test() {
check_parse_float("1", "00000017881393432617187501", 0, 1.0000002_f32);
check_parse_float("", "000000000000000000000000000000000000011754943508222875079687365372222456778186655567720875215087517062784172594547271728515625", 0, 1.1754943508222875e-38f32);
+
+ check_parse_float("0", "00000000000000000018", 0, 0.00000000000000000018_f32);
}
#[test] Running the tests in debug mode I get the panic:
In release mode though the parsing succeeds, but the float comparison fails:
The floating point comparison failure is expected (the closest representable value is According to
Isn't that too dangerous? I mean, I'm not controlling the value being sent to In an ideal world, |
could we have a BNF for the function to respect ? similar to what f64::from_str define: Float ::= Sign? ( 'inf' | 'NaN' | Number )
Number ::= ( Digit+ |
Digit+ '.' Digit* |
Digit* '.' Digit+ ) Exp?
Exp ::= [eE] Sign? Digit+
Sign ::= [+-]
Digit ::= [0-9] |
Might as well avoid the dep until rust-bakery/nom#1421 is fixed which is blocked on Alexhuszagh/minimal-lexical#7
Might as well avoid the dep until rust-bakery/nom#1421 is fixed which is blocked on Alexhuszagh/minimal-lexical#7
Description
Parsing long numbers can result in a panic. This was reported in nom: rust-bakery/nom#1421
Parsing a text like "0.00000000000000000087" results in this stacktrace:
I'm wondering if this should be solved in nom or minimal-lexical? I'm not sure nom has enough info to evaluate if the float will be too large
The text was updated successfully, but these errors were encountered: