Skip to content

fast-floats is unsound [nightly-only crate] #743

@scottmcm

Description

@scottmcm

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 FF32s with 0.0 and dividing them.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    UnsoundInformational / Unsound

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions