-
Notifications
You must be signed in to change notification settings - Fork 72
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
to_float and infinity result can crash vector #1107
Comments
Prior to this commit, string values that would exceed the f64 bounds would return `f64::INFINITY`. This leaks a type into the VRL scripts that could cause a panic without support to check for the value. Fixes vectordotdev#1107
Thanks @dhable, I will take a look. Need to think a bit about the breaking behavior of this change. |
I think the proposed (breaking) change makes sense. See playground examples. We can make the check even stricter by using is_normal. |
Prior to this commit, string values that would exceed the f64 bounds would return `f64::INFINITY`. This leaks a type into the VRL scripts that could cause a panic without support to check for the value. Fixes vectordotdev#1107
Prior to this commit, string values that would exceed the f64 bounds would return `f64::INFINITY`. This leaks a type into the VRL scripts that could cause a panic without support to check for the value. Fixes vectordotdev#1107 Co-authored-by: Pavlos Rontidis <pavlos.rontidis@gmail.com>
Prior to this commit, string values that would exceed the f64 bounds would return `f64::INFINITY`. This leaks a type into the VRL scripts that could cause a panic without support to check for the value. Fixes #1107 Co-authored-by: Pavlos Rontidis <pavlos.rontidis@gmail.com>
FYI: The fix was reverted and we (Vector team) will have to revisit this issue. I reproduced this crash in Vector with this config:
The current approach in VRL is to never allow special I want to address this holistically in VRL by providing safe arithmetic operations This is a difficult problem so the most probable scenario is following the Rust APIs e.g. checked_add. |
We ran into an issue where parsing a string with
to_float
exceeds the bounds off64::MAX
, which returns a non-error infinity value.Since
err
wasnull
, it's might seem like it's safe to perform operations on this value but subtraction causes vector to panic and crash. This is becausef64::INFINITY - f64::INFINITY == f64::NAN
in rust.I can't find anything in the VRL language, besides using
to_string
to compare with "inf", that would allow me to detect this situation and avoid operations on infinite values. IMHO, I would have expected an error result instead of infinity, similar to howto_int
behaves.The text was updated successfully, but these errors were encountered: