-
-
Notifications
You must be signed in to change notification settings - Fork 90
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
Zvariant asserts on f32::NAN values #1145
Comments
Freaking floating points and NaNs. :)
I'd rather prefer the latter since it's not a nice thing to not be able to handle your own serialized data. Any chance you could provide a PR? |
I can try, didn't get it to build the tests due to the C deps last, so I haven't gotten a test-case integrated to check. I think a basic patch like this ought to do it, simply allowing Nan & Inf conversions to happen as-is.
|
What C deps? you mean glib dep? That's only a dev-dep and you can easily disable it in the Cargo.toml w/o any issues (it's only needed for gvariant feature, which is disabled by default). Besides doesn't your distro package glib? |
The range check would fail on NAN, INFINITY and NEG_INFINITY even if they are completely valid things to decode. This does not promise that an encoded NAN will be bit-wise identical as the decoded NAN, but if signalling NAN is used that precisely the user can have a handful of more interesting problems. Issue: dbus2#1145
I had glib, but I was also a bit pressed on time and when compiling ended up with another C splat of deps I just shrugged and moved on rather than figure out the deps needed that time. ( I had had enough of that from fightiing with python and incompatible libxml+libxslt versions that day. ) Anyhow, PR is up and works on my machine (tm) |
The range check would fail on NAN, INFINITY and NEG_INFINITY even if they are completely valid things to decode. This does not promise that an encoded NAN will be bit-wise identical as the decoded NAN, but if signalling NAN is used that precisely the user can have a handful of more interesting problems. Fixes: dbus2#1145
Seems that f32::NAN get serialized to dbus as f64::NAN, but when read back again, it passes through an assert! statement that the value is in acceptable range for f32 and thus panics the application.
A suitable fix might be to either return an Result error rather than panic in a function that returns an Result, or simply convert f64::NAN to f32::NAN and hope nobody notices that it's not the same NAN value?
Testcase:
The text was updated successfully, but these errors were encountered: