Bug 149986 - pow() crashes, and exp() gives negative results on certain operands when used in IEEE upward rounding mode
pow() crashes, and exp() gives negative results on certain operands when used...
Product: Fedora
Classification: Fedora
Component: glibc (Show other bugs)
x86_64 Linux
medium Severity high
: ---
: ---
Assigned To: Jakub Jelinek
Brian Brock
Depends On:
  Show dependency treegraph
Reported: 2005-03-01 03:18 EST by David Monniaux
Modified: 2007-11-30 17:11 EST (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2005-03-01 05:15:12 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)
first example (pow() crash) (270 bytes, text/plain)
2005-03-01 03:19 EST, David Monniaux
no flags Details
exp() yields negative result (807 bytes, text/plain)
2005-03-01 03:20 EST, David Monniaux
no flags Details

  None (edit)
Description David Monniaux 2005-03-01 03:18:40 EST
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.7.3) Gecko/20040913

Description of problem:
On AMD64: after a fesetround(FE_UPWARD) (ISO C99 standard function for changing IEEE arithmetics rounding mode to round-to-plus-infinity, i.e. round to the nearest greater or equal representable value), pow() on certain operands will result in a segmentation fault, and exp() on some operands will yield negative results (the exponential of a real number is never negative).

Version-Release number of selected component (if applicable):

How reproducible:

Steps to Reproduce:
1) x=79.252413924118542354335659183561801910400390625, y=0.333333299999999999041477849459624849259853363037109375
2) fesetround(FE_UPWARD);
3a) pow(x, y)
3b) exp(log(x)*y)
(see attachment)

Actual Results:  3a) Segmentation fault.
3b) result = -0.246008

Expected Results:  Both programs should have given something around 4.295405, as it happens on IA32.

Additional info:

The glibc code (e_pow.c) that is used for some computations states, in a comment:
"Assumption: Machine arithmetic operations are performed in round to nearest
mode of IEEE 754 standard."

The bug has been filed in glibc bugzilla (http://sources.redhat.com/bugzilla/show_bug.cgi?id=763).

This bug has resulted in annoying crashes in scientific code doing interval arithmetic.
Comment 1 David Monniaux 2005-03-01 03:19:32 EST
Created attachment 111517 [details]
first example (pow() crash)
Comment 2 David Monniaux 2005-03-01 03:20:06 EST
Created attachment 111518 [details]
exp() yields negative result
Comment 3 Jakub Jelinek 2005-03-01 05:15:12 EST
There is no reason to duplicate the report here.
FYI, #1 certainly doesn't crash for me and #2 doesn't yield negative value.
This is with glibc-2.3.4-2.fc3.x86_64.rpm.
It doesn't yield 4.2954 though, but 8.02056.
Comment 4 David Monniaux 2005-03-01 05:50:09 EST
The first definitely crashes on FC2. What does pow(x,y) give on FC3/x86_64?
(Note: exp() giving 8 instead of 4.2 seems like a wild result too...)

Note You need to log in before you can comment on or make changes to this bug.