Bug 13705 - Bogus FPE on underflow for exp(double)
Summary: Bogus FPE on underflow for exp(double)
Status: RESOLVED FIXED
Alias: None
Product: glibc
Classification: Unclassified
Component: math (show other bugs)
Version: 2.15
: P2 normal
Target Milestone: ---
Assignee: Aurelien Jarno
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-02-17 21:08 IST by law
Modified: 2014-06-26 15:21 IST (History)
2 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:
fweimer: security-


Attachments
testcase (394 bytes, text/plain)
2012-02-17 21:08 IST, law
Details

Note You need to log in before you can comment on or make changes to this bug.
Description law 2012-02-17 21:08:39 IST
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 IST
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 IST
This is a different bug than the one fixed by the link I gave above.
Comment 3 Robin 2012-02-20 22:32:43 IST
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 IST
Patches posted on:

http://sourceware.org/ml/libc-alpha/2012-02/msg00446.html
Comment 5 Joseph Myers 2012-04-08 22:50:24 IST
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).