Bug 825999 - Some floating point operations return unpredictable result in different rounding modes
Summary: Some floating point operations return unpredictable result in different round...
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Fedora
Classification: Fedora
Component: glibc
Version: 17
Hardware: x86_64
OS: Linux
unspecified
high
Target Milestone: ---
Assignee: Jeff Law
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2012-05-29 10:08 UTC by Mikhail Kulemin
Modified: 2016-11-24 15:49 UTC (History)
5 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2012-05-29 16:55:37 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)
Simple test code for pow() (455 bytes, text/x-csrc)
2012-05-29 10:08 UTC, Mikhail Kulemin
no flags Details

Description Mikhail Kulemin 2012-05-29 10:08:42 UTC
Created attachment 587376 [details]
Simple test code for pow()

Description of problem:
Some functions from libm library (in glibc) return unpredictable result in non default rounding mode. Functions are: exp, pow etc. 


Version-Release number of selected component (if applicable): In RHEL 5.x 6.x, Fedora 16


How reproducible:
Always


Steps to Reproduce:
1.Compile simple code 

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <fenv.h>

static int modes[4] = { FE_TONEAREST, FE_TOWARDZERO, FE_DOWNWARD, FE_UPWARD };

int main (int argc, char *argv[])
{
	int i;
	char *end;
	double x = strtod (argv[1], &end);
	if (*end != '\0')
		exit (EXIT_FAILURE);

	for (i = 0; i < 4; i++)
        {
		double y;
		fesetround (modes[i]);
		y = pow (x,-0.34);
		printf ("pow(%.17g,-0.34) = %.17g\n", x, y);
        }
	return 0;
}

with gcc: "gcc -lm -o round_mode_test round_mode_test.c"
2. Run test code with some input number
$ ./round_mode_test 2
pow(2,-0.34) = 0.79004131186337712
pow(2,-0.34) = 0.50032986487121911
pow(2,-0.34) = 0.50032986487121911
pow(2,-0.34) = 0.79004131186337723
$ ./round_mode_test 0.9
pow(0.90000000000000002,-0.34) = 1.0364719344786322
pow(0.90000000000000002,-0.34) = 1.036471934478632
pow(0.90000000000000002,-0.34) = 1.036471934478632
pow(0.90000000000000002,-0.34) = 0.0061468530371330907

  
Actual results:
Different result in different rounding mode

Expected results:
Same results

Additional info:
This is glibc bug http://sources.redhat.com/bugzilla/show_bug.cgi?format=multiple&id=3976 with bugfix available.

Comment 1 Mikhail Kulemin 2012-05-29 10:12:54 UTC
There are some values which cause segfault in pow() function too.

Comment 2 Jeff Law 2012-05-29 16:55:37 UTC
This was fixed when I pulled in the current glibc develoment sources into Rawhide.  I do not currently have plans to backport these changes into F17.  However, obviously, they will be in F18.


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