Commit 3041856
fix(math): raise FE_DIVBYZERO/FE_INVALID for log/tgamma poles+domain (glibc parity)
Found via FP-exception differential probe: log(0)/log(-1)/tgamma(neg-integer)
returned the correct VALUE but raised NO floating-point exception, while glibc
raises FE_DIVBYZERO (log pole) / FE_INVALID (log domain, tgamma pole). The
libm-backed special-input paths special-case the result and bypass the hardware
op that would set the flag. Programs using feenableexcept/fetestexcept (e.g.
scientific NaN-trapping) depend on these.
Fix: re-raise the exception on the COLD special-input path via a safe hardware
op (force_eval-style, the hot path is unaffected):
log(±0) -> FE_DIVBYZERO via black_box(-1.0)/black_box(0.0) (= -inf)
log(x<0) -> FE_INVALID via black_box(0.0)/black_box(0.0) (= NaN)
tgamma(negative integer) -> FE_INVALID likewise
sqrt/log2/log10/exp/pow/acos/asin/acosh/atanh/fmod were already correct.
Gate: conformance_diff_fp_exceptions checks both the raised flags (exact) and
the returned value (<=4 ULP / NaN-inf-category) vs host glibc across domain/pole/
overflow inputs. All 155 math lib tests pass.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>1 parent 4806dd0 commit 3041856
3 files changed
Lines changed: 84 additions & 0 deletions
File tree
- crates
- frankenlibc-abi/tests
- frankenlibc-core/src/math
Lines changed: 67 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
45 | 55 | | |
46 | 56 | | |
47 | 57 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
189 | 189 | | |
190 | 190 | | |
191 | 191 | | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
192 | 199 | | |
193 | 200 | | |
194 | 201 | | |
| |||
0 commit comments