-
Notifications
You must be signed in to change notification settings - Fork 365
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
fast-floats is unsound [nightly-only crate] #743
Comments
Have you reported this to the fast-float developers? |
I have not. Given the description of "experimental and unstable; for experiments" I suspect they know, or at least wouldn't be too concerned about it. I was just trying to come up with an appropriate place to discourage its accidental use outside of those contexts, given that it's sometimes recommended to people (like https://users.rust-lang.org/t/whats-the-equivalent-of-icc-fp-model-fast-2/55110/2?u=scottmcm). |
I believe the way forward here is to report this to the upstream issue tracker. If this is by design, and they have no plans to remove the issue anytime soon, it seems reasonable to issue an advisory. |
cc @bluss . the repo does not seem to have an issue tracker, https://github.com/bluss/fast-floats. |
Hi. It was last discussed here. bluss/fast-floats#1 (comment) I.e it's a know issue, but nothing's using this crate. Fixing it would be the next step - if it had development. I would say it's reasonable if I update it with an 0.2 version and make the constructors @scottmcm: The crate as published implements all assign-ops as |
version 0.2.0 is now released. I wouldn't mind if it's marked unmaintained, but I guess let's do whatever is less fuss.
This is still true, but the constructor for Fast requires
|
https://lib.rs/crates/fast-floats
The crate exposes the
fadd_fast
(and similar) intrinsics to safe code behind the operator traits:https://docs.rs/fast-floats/0.1.2/src/fast_floats/lib.rs.html#93-101
This is unsound because using NAN as an argument to one of those intrinsics produces
poison
:https://llvm.org/docs/LangRef.html#fast-math-flags
Which can then be used to produce UB by using it "as an instruction operand that has any values that trigger undefined behavior":
https://llvm.org/docs/LangRef.html#poisonvalues
And one can directly create a NAN
FF32
in safe code:https://docs.rs/fast-floats/0.1.2/src/fast_floats/lib.rs.html#61
(As well as in other ways, like creating
FF32
s with0.0
and dividing them.)The text was updated successfully, but these errors were encountered: