Bug 13705

Summary: Bogus FPE on underflow for exp(double)
Product: glibc Reporter: law
Component: mathAssignee: Aurelien Jarno <aurelien>
Status: RESOLVED FIXED    
Severity: normal CC: aurelien, rjrw
Priority: P2 Flags: fweimer: security-
Version: 2.15   
Target Milestone: ---   
Host: Target:
Build: Last reconfirmed:
Attachments: testcase

Description law 2012-02-17 21:08:39 UTC
Created attachment 6225 [details]
testcase

With floating point trapping enabled, *except* for "underflow"
and "inexact", exp(-1.0e40) will throw a Floating Point Exception.

How reproducible:
Every time.

Steps to Reproduce:
1. Compile attached test programme (g++ test1.cpp)
2. Run program
3.

Actual results:
Floating point exception.

Expected results:
The value 0 should be printed.
Comment 1 Aurelien Jarno 2012-02-18 12:15:48 UTC
This should be fixed by:

http://sourceware.org/ml/libc-alpha/2012-02/msg00299.html
Comment 2 Aurelien Jarno 2012-02-20 06:34:17 UTC
This is a different bug than the one fixed by the link I gave above.
Comment 3 Robin 2012-02-20 22:32:43 UTC
At lines 35 and 40 of w_exp.c, libm uses the floating point variant "kernel_standard_f" rather than the double variant "kernel_standard".

The implementation of kernel_standard_f in k_standard.c just maps double to float (for arguments and return value).  If kernel_standard_f is changed to kernel_standard in both places, the test program runs through without problems.
Comment 4 Aurelien Jarno 2012-02-21 13:52:31 UTC
Patches posted on:

http://sourceware.org/ml/libc-alpha/2012-02/msg00446.html
Comment 5 Joseph Myers 2012-04-08 22:50:24 UTC
I have committed this patch as:

commit f77f12320635155da728a3c1adb75ff9914cf686
Author: Aurelien Jarno <aurelien@aurel32.net>
Date:   Sun Apr 8 22:45:13 2012 +0000

    Use __kernel_standard instead of __kernel_standard_f in exp wrapper (bug 13705).

and the obvious testcase patch for it as:

commit d2de7579f257386ba5c28dfca94fa8aef143b4e0
Author: Joseph Myers <joseph@codesourcery.com>
Date:   Sun Apr 8 22:46:49 2012 +0000

    Do not allow overflow exception on exp underflow test (bug 13705).