New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
math test fails on Solaris 10 #47417
Comments
There are 2 math test failures with 32-bit Python 2.6b1 and 3.0b1 on ====================================================================== Traceback (most recent call last):
File "Lib/test/test_math.py", line 419, in testLog
self.assertRaises(ValueError, math.log, NINF)
AssertionError: ValueError not raised ====================================================================== Traceback (most recent call last):
File "Lib/test/test_math.py", line 441, in testLog10
self.assertRaises(ValueError, math.log10, NINF)
AssertionError: ValueError not raised |
I'll take a look. |
Could you tell me what
gives instead of the expected ValueError? |
Here is that in from 32- and 64-bit Python 2.6b1: > ./python (32-bit)
Python 2.6b1 (r26b1:64398, Jun 20 2008, 09:20:49) [C] on sunos5
Type "help", "copyright", "credits" or "license" for more information.
>>> import math
>>> math.log(float('-inf'))
-inf
>>> math.log(float('inf'))
inf
>>> math.log(float('nan'))
nan
> ./python (64-bit)
Python 2.6b1 (r26b1:64398, Jun 19 2008, 20:27:39) [C] on sunos5
Type "help", "copyright", "credits" or "license" for more information.
>>> import math
>>> math.log(float('-inf'))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: math domain error
>>> math.log(float('inf'))
inf
>>> math.log(float('nan'))
nan Look like a Sun issue, doesn't it? |
Judging by the information at http://docs.sun.com/app/docs/doc/802-1930-03/6i5u95u0i? this behaviour is intentional. It looks like log(-inf) I've no idea why the 64-bit build doesn't exhibit math_1 in Modules/mathmodule.c bases its error reporting Unfortunately, changing this would likely cause failures One obvious solution is to write a matherr function |
On second thoughts, forget about matherr---looks like it's |
Here is a simple test case, demonstrating the issue. #include <errno.h>
#include <math.h>
#include <stdio.h>
int main(int argc, char *argv[])
{
printf("%f %d\n", log(-HUGE_VAL), errno);
printf("%f %d\n", log( HUGE_VAL), errno);
} result is different for 32- and 64-bit
#define EDOM 33 in /usr/include/sys/errno.h |
On Mon, Jun 23, 2008 at 5:25 PM, Jean Brouwers <report@bugs.python.org>
That 33 for the second log call may just be the propagated errno value Mark |
Right on! With errno = 0; in between both calls: -Inf 33 /Jean On Tue, Jun 24, 2008 at 1:17 PM, Mark Dickinson <report@bugs.python.org> wrote:
|
Mark, Take a look at the SUN forum, there is a (long) answer. <http://forum.java.sun.com/thread.jspa?threadID=5308106&tstart=0\> /Jean On Tue, Jun 24, 2008 at 3:37 PM, Jean Brouwers <report@bugs.python.org> wrote:
>
> Jean Brouwers <MrJean1@Gmail.com> added the comment:
>
> Right on! With errno = 0; in between both calls:
>
> -Inf 33
> Inf 0
>
> /Jean
>
> On Tue, Jun 24, 2008 at 1:17 PM, Mark Dickinson <report@bugs.python.org> wrote:
>>
>> Mark Dickinson <dickinsm@gmail.com> added the comment:
>>
>> On Mon, Jun 23, 2008 at 5:25 PM, Jean Brouwers <report@bugs.python.org>
>> wrote:
>>
>>> result is different for 32- and 64-bit
>>>
>>> > cc -xtarget=native log_inf.c -lm ; a.out
>>> -Inf 33
>>> Inf 33
>>>
>>
>> That 33 for the second log call may just be the propagated errno value
>> from the first call. Could you try setting errno = 0 before each of the
>> printf
>> calls? I'd expect that log(HUGE_VAL) doesn't set errno at all.
>>
>> Mark
>>
>> Added file: http://bugs.python.org/file10722/unnamed
>>
>> _______________________________________
>> Python tracker <report@bugs.python.org>
>> <http://bugs.python.org/issue3167>
>> _______________________________________
>
> _______________________________________
> Python tracker <report@bugs.python.org>
> <http://bugs.python.org/issue3167>
> _______________________________________
> |
Nice reply from zal. His conclusion:
It sounds like using the -xlibmieee flag is the way to go. (math_1 is Could you try compiling with this flag to see whether it fixes the |
Unless I am doing something wrong, that flag does not fix the problem. #include <errno.h>
#include <math.h>
#include <stdio.h>
int main(int argc, char *argv[])
{
errno = 0;
printf("%f %d\n", log(-HUGE_VAL), errno);
errno = 0;
printf("%f %d\n", log( HUGE_VAL), errno);
} /* result is different for 32- and 64-bit
#define EDOM 33 in /usr/include/sys/errno.h */ |
Sorry, the flag *does* make a difference. Ignoring errno, the results for |
Does that mean that both do the right thing or the wrong thing? |
The 64-bit version did the right thing, all along. The 32-bit result is But the latter sets errno value to EDOM and that should be 0, rather |
Jean, Could you try the attached patch and see if it fixes the problem? And I'd welcome comments from others on the patch---I'm not much of an |
The patch <http://bugs.python.org/file10754/issue3167.patch\> does not cc -c -xtarget=native -xlibmieee -DNDEBUG -xO5 -I. .... However, the resulting build produces to wrong result: Python 2.6b1 (r26b1:64398, Jun 27 2008, 18:04:19) [C] on sunos5
Type "help", "copyright", "credits" or "license" for more information.
>>> import math
>>> math.log(float('-inf'))
-inf |
Darn. That's probably because the linker needs the extra flag as well. Here's a revised patch for you to try. (You might need to do an "svn up" |
Keep in mind also, these Python builds are compiled with the SUN Using -xlibmieee in 3 places, BASECFLAGS, LDFLAGS and LDSHARED and Python 2.6b1 (r26b1:64398, Jun 28 2008, 10:31:27) [C] on sunos5 >>> import cmath
>>> cmath.log(100.0)
(4.6051701859880918+0j)
>>> cmath.log(2.0)
(0.69314718055994529+0j)
>>> cmath.log(100.0, 2.0)
(6.6438561897747253+0j)
>>> import math
>>> math.log(float('-inf'))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: math domain error |
The 32-but results are the same when built with -xO5. Python 2.6b1 (r26b1:64398, Jun 28 2008, 10:43:53) [C] on sunos5
Type "help", "copyright", "credits" or "license" for more information.
>>> import cmath
>>> cmath.log(100.0)
(4.6051701859880918+0j)
>>> cmath.log(2.0)
(0.69314718055994529+0j)
>>> cmath.log(100.0, 2.0)
(6.6438561897747253+0j)
>>> import math
>>> math.log(float('-inf'))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: math domain error |
Right. That's the purpose of the 'if's and 'case' tests in the Do you happen to know which versions of Solaris support the -xlibmieee |
The SUN compiler versions
Both define the following symbols: #define __SUNPRO_C 0x580
#define __SunOS_5_10 |
Okay, here's a third version of the patch. Same as before, except Jean, does this patch fix the problem with math.log on 32-bit? If so, |
Sorry, my previous post was wrong. The LDSHARED symbol did NOT include - |
I applied your patch to freshly updated configure and configure.in files The resulting Makefile has empty BASECFLAGS and LDFLAGS. Here is the .... |
Sorry---my bad. I missed out the $ac_sys_release bit. Patch updated again. Jean, could you please give it one more try? |
Yep, that one works. As before, using ./configure --without-gcc ... .... |
Add comment to patch. |
Martin, Do you have a moment to do a sanity check on the attached patch? The I'm not very sure of myself when it comes to messing with autoconf, so |
Dunno about Sun's compiler, but I get test errors on Solaris 10 using ====================================================================== Traceback (most recent call last):
File "/home/tuba/skipm/src/python-svn/trunk/Lib/test/test_cmath.py",
line 338, in test_specific_values
self.fail('OverflowError not raised in test %s' % test_str)
AssertionError: OverflowError not raised in test exp0052:
exp(complex(710.0, 1.5)) Ran 11 tests in 0.067s FAILED (failures=1)
test test_cmath failed -- Traceback (most recent call last):
File "/home/tuba/skipm/src/python-svn/trunk/Lib/test/test_cmath.py",
line 338, in test_specific_values
self.fail('OverflowError not raised in test %s' % test_str)
AssertionError: OverflowError not raised in test exp0052:
exp(complex(710.0, 1.5)) ====================================================================== Traceback (most recent call last):
File "/home/tuba/skipm/src/python-svn/trunk/Lib/test/test_math.py",
line 419, in testLog
self.assertRaises(ValueError, math.log, NINF)
AssertionError: ValueError not raised ====================================================================== Traceback (most recent call last):
File "/home/tuba/skipm/src/python-svn/trunk/Lib/test/test_math.py",
line 441, in testLog10
self.assertRaises(ValueError, math.log10, NINF)
AssertionError: ValueError not raised |
Okay---so committing this would be premature at this point. It looks like the test_math errors are the same problem that Jean found. LDFLAGS=-xlibmieee ./configure ... do anything to alleviate the test_math errors? The cmath problems look like a new issue. |
I guess that should probably be: LDFLAGS="-Xlinker -xlibmieee" ./configure |
Skip: one more question. What does cmath.exp(710.0 + 1.5j) give instead of the expected OverflowError? Incidentally, the Solaris buildbot seems happy enough at the moment. I |
For comparison, 64-bit -xO5 Python build: Python 2.6b1 (r26b1:64398, Jun 28 2008, 12:50:06) [C] on sunos5
Type "help", "copyright", "credits" or "license" for more information.
>>> import cmath
>>> cmath.exp(710.0 + 1.5j)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
OverflowError: math range error
>>> cmath.log(100,2)
(0.71244151439608006-2.0556716794852954j)
>>> cmath.log(complex(100,0), complex(2,0))
(0.71244151439608006-2.0556716794852954j) 64-bit -xO0 Python build: Python 2.6b1 (r26b1:64398, Jun 28 2008, 11:02:57) [C] on sunos5
Type "help", "copyright", "credits" or "license" for more information.
>>> import cmath
>>> cmath.exp(710.0 + 1.5j)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
OverflowError: math range error
>>> cmath.log(100,2)
(6.6438561897747253+0j)
>>> cmath.log(complex(100,0), complex(2,0))
(6.6438561897747253+0j) |
What about this case? Should cmath not produce the same result as math: >>> math.log(float('-inf'))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: math domain error
>>> cmath.log(float('-inf'))
(inf+3.1415926535897931j)
>>> cmath.log(complex(float('-inf'), 0))
(inf+3.1415926535897931j) This occurs in all 32- and 64-bit builds (with -xlibmieee and SUN C) on |
No; this is correct, I think. Note that the cmath.log result has nonzero Similarly, math.sqrt(-1) is an error, while cmath.sqrt(-1) returns a |
I tried to configure with '-Xlinker -xlibmieee' added to LDFLAGS. Failed ... Skip |
I'm pretty much out of ideas here. Skip, if you have any time to figure The actual function call takes place in math_1, in the line Is /usr/bin/ccs/ld Sun's own linker? If so, why doesn't it accept the - |
Some other possibilities to try. This page: http://www.redhat.com/docs/wp/solaris_port/x99.html seems to suggest that linking with -lieee, and possibly also adding the - |
Here's a gdb session using r64812. gcc 4.2.2. ldd on math.so shows: % ldd build/lib.solaris-2.10-i86pc-2.6/math.so % gdb ./python Breakpoint 1 (math_1) pending.
(gdb) r
Starting program: /home/tuba/skipm/src/python-svn/trunk/build/python
Python 2.6b1+ (trunk:64812M, Jul 8 2008, 20:43:40)
[GCC 4.2.2] on sunos5
Type "help", "copyright", "credits" or "license" for more information.
>>> import math
>>> inf = float('inf')
>>> math.log(-inf) Breakpoint 1, math_1 (arg=0x81f1fbc, func=0x805e88c <log@plt>, Does this help? I don't know how to tell where log@plt is resolved, but As for the /usr/ccs/bin/ld thing, it doesn't look like we are using it, % gcc --verbose -L/opt/app/nonc++/ncurses-5.6/lib - I don't see /usr/ccs/bin/ld mentioned. Skip |
Regarding -lieee, I don't see an ieee library on my system. Regarding -ffast-math, while it changes the log function which is linked % ldd build/lib.solaris-2.10-i86pc-2.6/math.so Breakpoint 1 (math_1) pending.
(gdb) r
Starting program: /home/tuba/skipm/src/python-svn/trunk/build/python
Python 2.6b1+ (trunk:64812M, Jul 8 2008, 21:40:26)
[GCC 4.2.2] on sunos5
Type "help", "copyright", "credits" or "license" for more information.
im>>> import math
>>> inf = float('inf')
>>> math.log(-inf) Breakpoint 1, math_1 (arg=0x81f19bc, func=0xfee2d6a0 <log>, |
The /lib/libm.so.* files on my Solaris 10 (Opteron) box are equally old:
Also, this looks like a more recent patch for the Math libraries, under 3.2: <http://developers.sun.com/sunstudio/downloads/express_readme.html\> Then thare are the Studio patches SUN recommended the other day: <http://developers.sun.com/sunstudio/downloads/patches/ss11_patches.html\> If things change after I install those, I will certainly let you know. /Jean Brouwers |
Skip, Jean: Could you try the attached patch to see if it fixes the math.log and |
Mark> Could you try the attached patch to see if it fixes the math.log Seems to work on Sol10 for me:
Skip |
It looks like the patch did fix the problems. Attached are the results The math log tests failed with the 32-bit build before and passed after |
Thanks, both! Fixed in the trunk in r67707. I'll wait to be sure that the buildbots are |
Buildbots seem content. Merged to 2.6, 3.0, 3.1. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: