Red Hat Bugzilla – Bug 149986
pow() crashes, and exp() gives negative results on certain operands when used in IEEE upward rounding mode
Last modified: 2007-11-30 17:11:01 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):
Steps to Reproduce:
1) x=79.252413924118542354335659183561801910400390625, y=0.333333299999999999041477849459624849259853363037109375
3a) pow(x, y)
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.
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.
Created attachment 111517 [details]
first example (pow() crash)
Created attachment 111518 [details]
exp() yields negative result
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.
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...)