Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20261115190829.GD3542221@port70.net>
Date: Sun, 15 Nov 2026 20:08:29 +0100
From: Szabolcs Nagy <nsz@...t70.net>
To: 郭军凯 <guojunkai26@....pku.edu.cn>
Cc: musl@...ts.openwall.com
Subject: Re: Potential issues in musl math functions

* 郭军凯 <guojunkai26@....pku.edu.cn> [2026-11-16 01:36:23 +0800]:
> Hello,
> We are developing a software verification tool and observed several potential issues while testing musl’s math library.
> The attached report lists the affected functions, inputs, rounding modes, observed results, and a brief analysis of the causes.

thanks these looks valid,
the fma one is already fixed.
the sincosf one affects the standard sinf,cosf too.

> ## Classification by Cause
> 
> 1. **Propagation of negative zero (1–4, 8–13)**: For these inputs, subtraction under downward rounding produces `-0`. In `atanh/atanhf`, this makes `1-|x|` negative zero, so division produces `-Inf` and the subsequent call to `log1p` returns NaN. In `acosh/acoshf`, the negative zero from `x-1` propagates to the return value. The six entry points in the `lgamma` family return `-Inf` by evaluating `1/(x-x)` at negative integer poles.
> 
> 2. **Sign bit ignored when selecting a branch (5)**: When extracting the exponent, `acosh` masks out the sign bit, causing negative inputs to enter a branch intended for positive arguments. Taking the reciprocal amplifies the cancellation error in `x+sqrt(x*x-1)`, making the argument passed to `log` positive and producing a finite return value.
> 
> 3. **Zero sign changed when handling negative orders (6–7)**: For negative odd orders, `jn/jnf` set a flag indicating that the result must be negated. When the input is infinite, the computation first produces `+0`; applying the flag before returning changes it to `-0`.
> 
> 4. **Adding zero after product underflow (14–15)**: When `z=0`, the software implementation of `fma` directly evaluates `x*y+z`. The product first underflows to zero. Adding a zero of the opposite sign then changes its sign, so the result differs from rounding the exact multiply-add once. Both cases were reproduced in the software implementation on x86-64; musl builds that use hardware FMA may bypass this branch.
> 
> 5. **Negation after overshoot in the cosine kernel (16–17)**: When the reduced argument is close to zero, upward rounding causes `__cosdf` to return `1+2⁻²³`. Depending on the quadrant, `sincosf` then negates this value, producing a sine or cosine result of `-1-2⁻²³`, below `-1`.

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.