Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CABaUXi4NXooBaspkJ7oUReFzKKH8=NAeajJTjHqidMa-xMFpNg@mail.gmail.com>
Date: Mon, 10 Aug 2026 18:24:55 +0100
From: Sergey Davidoff <shnatsel@...il.com>
To: musl@...ts.openwall.com
Subject: Re: Bug in fmaf: subnormals are rounded incorrectly

Rich wrote:
> If this test is the only thing causing it to be wrong, it could easily
> be adjusted to work with subnormals that are halfway cases, or to just
> handle all subnormals in this code path if that works.

Incorrect rounding of subnormals is the only bug I am aware of, but I do not
think that adjusting that condition alone is sufficient.

I am hesitant to invent a novel algorithm here because the input space is large
(2 to the 96th power) and the failure cases are sparse, so exhaustive
verification is intractable and random search won't find this kind of bug.

I suggest following this paper which contains a formally proven algorithm:
https://guillaume.melquiond.fr/doc/08-tc.pdf

I've originally encountered this bug in the Rust standard library, which
derives its software f32 FMA from musl (which derives from FreeBSD).
Here is my reading of the algorithm from the paper applied to it:
https://github.com/rust-lang/compiler-builtins/pull/1270/changes

The diff is not large, but it's not as simple as changing one condition either.

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.