Repository navigation
Closed
Description
| BPO | 3167 |
|---|---|
| Nosy | @loewis, @smontanaro, @terryjreedy, @mdickinson |
| Files |
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:
assignee = 'https://github.com/mdickinson'
closed_at = <Date 2008-12-11.22:06:17.642>
created_at = <Date 2008-06-21.21:47:19.307>
labels = ['type-bug', 'tests']
title = 'math test fails on Solaris 10'
updated_at = <Date 2008-12-11.22:06:17.641>
user = 'https://bugs.python.org/MrJean1'bugs.python.org fields:
activity = <Date 2008-12-11.22:06:17.641>
actor = 'mark.dickinson'
assignee = 'mark.dickinson'
closed = True
closed_date = <Date 2008-12-11.22:06:17.642>
closer = 'mark.dickinson'
components = ['Tests']
creation = <Date 2008-06-21.21:47:19.307>
creator = 'MrJean1'
dependencies = []
files = ['12251', '12307', '12308']
hgrepos = []
issue_num = 3167
keywords = ['patch']
message_count = 47.0
messages = ['68548', '68560', '68561', '68594', '68624', '68627', '68637', '68699', '68706', '68707', '68719', '68762', '68763', '68836', '68837', '68849', '68867', '68870', '68878', '68880', '68882', '68885', '68886', '68888', '68892', '68893', '68903', '68907', '68911', '68918', '68933', '68938', '68940', '68952', '68953', '68954', '68980', '69441', '69443', '69450', '69452', '69455', '77147', '77152', '77452', '77627', '77634']
nosy_count = 5.0
nosy_names = ['loewis', 'skip.montanaro', 'terry.reedy', 'mark.dickinson', 'MrJean1']
pr_nums = []
priority = 'high'
resolution = 'fixed'
stage = None
status = 'closed'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue3167'
versions = ['Python 2.6', 'Python 3.0', 'Python 3.1']
Activity
MrJean1 commentedon Jun 21, 2008
There are 2 math test failures with 32-bit Python 2.6b1 and 3.0b1 on
Solaris 10 both built with Sun's C compiler. The failures do *not*
occur for the 64-bit builds. The same compiler options are used for all
these builds (except -xtarget=native vs -xtarget=native64).
======================================================================
FAIL: testLog (main.MathTests)
----------------------------------------------------------------------
======================================================================
FAIL: testLog10 (main.MathTests)
----------------------------------------------------------------------
mdickinson commentedon Jun 22, 2008
I'll take a look.
mdickinson commentedon Jun 22, 2008
Could you tell me what
gives instead of the expected ValueError?
MrJean1 commentedon Jun 22, 2008
Here is that in from 32- and 64-bit Python 2.6b1:
Look like a Sun issue, doesn't it?
mdickinson commentedon Jun 23, 2008
Judging by the information at
http://docs.sun.com/app/docs/doc/802-1930-03/6i5u95u0i?
l=en&a=view&q=matherr
this behaviour is intentional. It looks like log(-inf)
sets errno = EDOM and returns -inf. An IEEE 754
conforming math library would return NaN instead.
I've no idea why the 64-bit build doesn't exhibit
this problem.
math_1 in Modules/mathmodule.c bases its error reporting
primarily on return values, only looking at errno in the
case when a finite value is returned. So it doesn't
ever take any notice of the EDOM errno value.
Unfortunately, changing this would likely cause failures
on other machines. GNU libc is all over the place when
it comes to setting errno: I recall finding that on one
Linux machine, of the three calls atanh(1.), log(0.) and
log10(0.), one of these sets errno = EDOM, one sets errno
= ERANGE, and one doesn't set errno at all. (All three
calls correspond to logarithmic singularities, and should
all behave the same way.)
One obvious solution is to write a matherr function
for use on Solaris, as described on the man page
above. Do you think you could have a
go at this?
mdickinson commentedon Jun 23, 2008
On second thoughts, forget about matherr---looks like it's
outdated technology.
MrJean1 commentedon Jun 23, 2008
Here is a simple test case, demonstrating the issue.
result is different for 32- and 64-bit
mdickinson commentedon Jun 24, 2008
On Mon, Jun 23, 2008 at 5:25 PM, Jean Brouwers <report@bugs.python.org>
wrote:
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
MrJean1 commentedon Jun 24, 2008
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:
MrJean1 commentedon Jun 24, 2008
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
mdickinson commentedon Jun 25, 2008
Nice reply from zal. His conclusion:
It sounds like using the -xlibmieee flag is the way to go. (math_1 is
already doing an excellent job of not relying on errno).
Could you try compiling with this flag to see whether it fixes the
problem? (Opening up the 'configure' file and adding the flag to
BASECFLAGS might be the easiest way to do this; there may be easier
ways.) If it does, I'll cook up a configure patch.
MrJean1 commentedon Jun 25, 2008
Unless I am doing something wrong, that flag does not fix the problem.
/* result is different for 32- and 64-bit
*/
26 remaining items
MrJean1 commentedon Jun 29, 2008
What about this case? Should cmath not produce the same result as math:
This occurs in all 32- and 64-bit builds (with -xlibmieee and SUN C) on
Solaris 10 (Opteron) and on 32-bit MacOS X 10.4.11 (Intel) built with
gcc.
mdickinson commentedon Jun 29, 2008
No; this is correct, I think. Note that the cmath.log result has nonzero
imaginary part, so can't be represented as a float.
Similarly, math.sqrt(-1) is an error, while cmath.sqrt(-1) returns a
complex result and doesn't raise any exception.
smontanaro commentedon Jun 30, 2008
I tried to configure with '-Xlinker -xlibmieee' added to LDFLAGS. Failed
miserably. In fact, configure complained that my compiler couldn't create
executables, told me to look at config.log for details then logged me out
from the machine! It would appear gcc *really* doesn't like that
combination:
...
configure:2676: checking for C compiler default output file name
configure:2703: gcc -I/opt/app/nonc++/ncurses-5.6/include -
I/opt/app/nonc++/ncu
rses-5.6/include/ncurses -I/opt/app/nonc++/gdbm-1.8/include -
I/opt/app/nonc++/re
adline-4.3/include -I/opt/app/nonc++/tcl-8.4/include -
I/opt/app/nonc++/BerkleyDB
-4.3/include -L/opt/app/nonc++/ncurses-5.6/lib -R/opt/app/nonc++/ncurses-
5.6/lib
-L/opt/app/nonc++/gdbm-1.8/lib -R/opt/app/nonc++/gdbm-1.8/lib -
L/opt/app/nonc++
/readline-4.3/lib -R/opt/app/nonc++/readline-4.3/lib -L/opt/app/nonc++/tcl-
8.4/l
ib -R/opt/app/nonc++/tcl-8.4/lib -L/opt/app/nonc++/BerkleyDB-4.3/lib -
R/opt/app/
nonc++/BerkleyDB-4.3/lib -Xlinker -xlibmieee conftest.c >&5
/usr/ccs/bin/ld: illegal option -- x
usage: ld [-6:abc:d:e:f:h:il:mo:p:rstu:z:B:CD:F:GI:L:M:N:P:Q:R:S:VY:?]
file(s)
[-64] enforce a 64-bit link-edit
[-a] create an absolute file
[-b] do not do special PIC relocations in a.out
[-B direct | nodirect]
establish direct bindings, or inhibit direct binding
to, the object being created
...
Skip
mdickinson commentedon Jul 8, 2008
I'm pretty much out of ideas here. Skip, if you have any time to figure
out where the math.log call is going wrong, I'd appreciate it. On Jean's
machine, the problem was that the call log(-inf) to the C library's log
function was returning -inf instead of the expected nan.
The actual function call takes place in math_1, in the line
"r = (*func)(x)" (line 178 of Modules/mathmodule.c in the current trunk,
r64812). A couple of printf calls would show the inputs and outputs to
that function.
Is /usr/bin/ccs/ld Sun's own linker? If so, why doesn't it accept the -
xlibmieee option? (Or maybe it does, in which case the question is why
isn't gcc passing that option to ld properly.)
mdickinson commentedon Jul 8, 2008
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 -
ffast-math gcc option, might help.
smontanaro commentedon Jul 9, 2008
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
libm.so.2 => /lib/libm.so.2
libgcc_s.so.1 => /opt/app/nonc++/lib/libgcc_s.so.1
libc.so.1 => /lib/libc.so.1
% gdb ./python
GNU gdb 6.8
Copyright (C) 2008 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later
<http://gnu.org/licenses/gpl.html\>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show
copying"
and "show warranty" for details.
This GDB was configured as "i386-pc-solaris2.10"...
(gdb) b math_1
Function "math_1" not defined.
Make breakpoint pending on future shared library load? (y or [n]) y
Breakpoint 1, math_1 (arg=0x81f1fbc, func=0x805e88c <log@plt>,
can_overflow=0)
at /home/tuba/skipm/src/python-svn/trunk/Modules/mathmodule.c:171
171 {
(gdb) p func
$1 = (double (*)(double)) 0x805e88c <log@plt>
(gdb) n
173 x = PyFloat_AsDouble(arg);
(gdb) n
174 if (x == -1.0 && PyErr_Occurred())
(gdb) x
0x0: Cannot access memory at address 0x0
(gdb) p x
$2 = -inf
(gdb) n
176 errno = 0;
(gdb) n
178 r = (*func)(x);
(gdb) n
180 if (Py_IS_NAN(r)) {
(gdb) p r
$3 = -inf
Does this help? I don't know how to tell where log@plt is resolved, but
I suppose it probably comes from /lib/libm.so.2. It's got a date on my
system of Jan 22 2005. Any idea how to tell if there's a Sun patch for
it?
As for the /usr/ccs/bin/ld thing, it doesn't look like we are using it,
at least not directly. Adding the --verbose flag to the link line I get
this output:
% gcc --verbose -L/opt/app/nonc++/ncurses-5.6/lib -
R/opt/app/nonc++/ncurses-5.6/lib -L/opt/app/nonc++/gdbm-1.8/lib -
R/opt/app/nonc++/gdbm-1.8/lib -L/opt/app/nonc++/readline-4.3/lib -
R/opt/app/nonc++/readline-4.3/lib -L/opt/app/nonc++/tcl-8.4/lib -
R/opt/app/nonc++/tcl-8.4/lib -L/opt/app/nonc++/BerkleyDB-4.3/lib -
R/opt/app/nonc++/BerkleyDB-4.3/lib -o python
Modules/python.o libpython2.6.a -lresolv -lsocket -lnsl
-lrt -ldl -lm
Reading specs from /opt/app/g++lib6/gcc-4.2/lib/gcc/i386-pc-
solaris2.10/4.2.2/specs
Target: i386-pc-solaris2.10
Configured with: ../configure --prefix=/opt/app/g++lib6/gcc-4.2 --
enable-languages=c,c++,fortran,objc --disable-nls --with-included-
gettext --with-gnu-as --with-as=/usr/sfw/bin/gas --with-target-
tools=/usr/sfw/bin/ --with-gmp=/opt/app/nonc++/gmp-4.2 --with-
mpfr=/opt/app/nonc++/mpfr-2.3
Thread model: posix
gcc version 4.2.2
/opt/app/g++lib6/gcc-4.2/libexec/gcc/i386-pc-solaris2.10/4.2.2/collect2
-V -R/opt/app/nonc++/lib -R/opt/app/g++lib6/lib -
R/opt/app/nonc++/ncurses-5.6/lib -R/opt/app/nonc++/gdbm-1.8/lib -
R/opt/app/nonc++/readline-4.3/lib -R/opt/app/nonc++/tcl-8.4/lib -
R/opt/app/nonc++/BerkleyDB-4.3/lib -Y P,/usr/ccs/lib:/usr/lib -Qy -o
python /usr/lib/crt1.o /usr/lib/crti.o /usr/lib/values-Xa.o
/opt/app/g++lib6/gcc-4.2/lib/gcc/i386-pc-solaris2.10/4.2.2/crtbegin.o -
L/opt/app/nonc++/ncurses-5.6/lib -L/opt/app/nonc++/gdbm-1.8/lib -
L/opt/app/nonc++/readline-4.3/lib -L/opt/app/nonc++/tcl-8.4/lib -
L/opt/app/nonc++/BerkleyDB-4.3/lib -L/opt/app/g++lib6/gcc-
4.2/lib/gcc/i386-pc-solaris2.10/4.2.2 -L/opt/app/g++lib6/gcc-
4.2/lib/gcc/i386-pc-solaris2.10/4.2.2/../../.. Modules/python.o
libpython2.6.a -lresolv -lsocket -lnsl -lrt -ldl -lm -lgcc -lgcc_eh -lc
-lgcc -lgcc_eh /opt/app/g++lib6/gcc-4.2/lib/gcc/i386-pc-
solaris2.10/4.2.2/crtend.o /usr/lib/crtn.o
ld: Software Generation Utilities - Solaris Link Editors: 5.10-1.482
I don't see /usr/ccs/bin/ld mentioned.
Skip
smontanaro commentedon Jul 9, 2008
Regarding -lieee, I don't see an ieee library on my system.
Regarding -ffast-math, while it changes the log function which is linked
to, it doesn't appear to modify the result of math.log:
% ldd build/lib.solaris-2.10-i86pc-2.6/math.so
libm.so.2 => /lib/libm.so.2
libgcc_s.so.1 => /opt/app/nonc++/lib/libgcc_s.so.1
libc.so.1 => /lib/libc.so.1
% gdb ./python
GNU gdb 6.8
Copyright (C) 2008 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later
<http://gnu.org/licenses/gpl.html\>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show
copying"
and "show warranty" for details.
This GDB was configured as "i386-pc-solaris2.10"...
(gdb) b math_1
Function "math_1" not defined.
Make breakpoint pending on future shared library load? (y or [n]) y
Breakpoint 1, math_1 (arg=0x81f19bc, func=0xfee2d6a0 <log>,
can_overflow=0)
at /home/tuba/skipm/src/python-svn/trunk/Modules/mathmodule.c:171
171 {
(gdb) func
Undefined command: "func". Try "help".
(gdb) p func
$1 = (double (*)(double)) 0xfee2d6a0 <log>
(gdb) n
173 x = PyFloat_AsDouble(arg);
(gdb) n
174 if (x == -1.0 && PyErr_Occurred())
(gdb) p x
$2 = -inf
(gdb) n
176 errno = 0;
(gdb) n
178 r = (*func)(x);
(gdb) n
186 else if (Py_IS_INFINITY(r)) {
(gdb) p r
$3 = -inf
MrJean1 commentedon Jul 9, 2008
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
mdickinson commentedon Dec 6, 2008
Skip, Jean:
Could you try the attached patch to see if it fixes the math.log and
math.log10 test failures. (The patch is generated against the trunk, but
should apply cleanly to py3k or either of the 2.6 or 3.0 maintenance
branches.
smontanaro commentedon Dec 6, 2008
Mark> Could you try the attached patch to see if it fixes the math.log
Mark> and math.log10 test failures. (The patch is generated against the
Mark> trunk, but should apply cleanly to py3k or either of the 2.6 or
Mark> 3.0 maintenance branches.
Seems to work on Sol10 for me:
Skip
MrJean1 commentedon Dec 9, 2008
It looks like the patch did fix the problems. Attached are the results
for 32- and 64-bit Python 2.6.1 with and without the patch, all built with
SUN's compilers on Solaris 10 (Opteron).
The math log tests failed with the 32-bit build before and passed after
applying the patch. The 64-bit build passed before and still passes after
the patch.
mdickinson commentedon Dec 11, 2008
Thanks, both!
Fixed in the trunk in r67707. I'll wait to be sure that the buildbots are
happy, then merge to 2.6, 3.0, 3.1.
mdickinson commentedon Dec 11, 2008
Buildbots seem content. Merged to 2.6, 3.0, 3.1.