Weird *** longjmp causes uninitialized stack frame *** error?

2,333 views
Skip to first unread message

KvS

unread,
Dec 23, 2010, 5:25:28 AM12/23/10
to sage-support
Hi all,

I'm very sorry, but I have yet another error I don't understand. I was
playing around with evaluating the gamma function. The following piece
of code is fine (on Sage v 4.6):

i=sqrt(-1)
for k in range(100):
print k; r1=random(); r2=random()
#try:
# xx=100*r1-i; yy=100*r2
# res=gamma(xx)*gamma(yy)/gamma(xx+yy)
#except:
# pass

If I now uncomment the last four lines (besides that I don't
understand the error itself, there should be no error at all because
of the try-except-block no?):

i=sqrt(-1)
for k in range(100):
print k; r1=random(); r2=random()
try:
xx=100*r1-i; yy=100*r2
res=gamma(xx)*gamma(yy)/gamma(xx+yy)
except:
pass

I get in every run somewhere in the loop an error, like this:

0
1
2
3
4
5
6
7
8
*** longjmp causes uninitialized stack frame ***:
/usr/local/Sage/sage-4.6-linux-32bit-ubuntu_10.04_lts-i686-Linux/local/
b\
in/python terminated
======= Backtrace: =========
/lib/libc.so.6(__fortify_fail+0x50)[0x2b2970]
/lib/libc.so.6(+0xe58da)[0x2b28da]
/usr/local/Sage/sage-4.6-linux-32bit-ubuntu_10.04_lts-i686-Linux/local/
l\
ib/libpari-gmp-2.4.so.3(pari_err+0x2ae)[0x255af0e]
======= Memory map: ========
00110000-00116000 r-xp 00000000 08:05 30103
/usr/local/Sage/sage-4.6-linux-32bit-ubuntu_10.04_lts-i686-Linux/local/
l\
ib/python2.6/lib-dynload/_struct.so
00116000-00117000 r--p 00005000 08:05 30103
/usr/local/Sage/sage-4.6-linux-32bit-ubuntu_10.04_lts-i686-Linux/local/
l\
ib/python2.6/lib-dynload/_struct.so
00117000-00119000 rw-p 00006000 08:05 30103
/usr/local/Sage/sage-4.6-linux-32bit-ubuntu_10.04_lts-i686-Linux/local/
l\
ib/python2.6/lib-dynload/_struct.so
00119000-0011d000 r-xp 00000000 08:05 30067
/usr/local/Sage/sage-4.6-linux-32bit-ubuntu_10.04_lts-i686-Linux/local/
l\
ib/python2.6/lib-dynload/strop.so
0011d000-0011e000 r--p 00003000 08:05 30067
/usr/local/Sage/sage-4.6-linux-32bit-ubuntu_10.04_lts-i686-Linux/local/
l\
ib/python2.6/lib-dynload/strop.so
0011e000-00120000 rw-p 00004000 08:05 30067
/usr/local/Sage/sage-4.6-linux-32bit-ubuntu_10.04_lts-i686-Linux/local/
l\
ib/python2.6/lib-dynload/strop.so
00120000-00125000 r-xp 00000000 08:05 30055
/usr/local/Sage/sage-4.6-linux-32bit-ubuntu_10.04_lts-i686-Linux/local/
l\
ib/python2.6/lib-dynload/_collections.so
00125000-00126000 r--p 00004000 08:05 30055
/usr/local/Sage/sage-4.6-linux-32bit-ubuntu_10.04_lts-i686-Linux/local/
l\
ib/python2.6/lib-dynload/_collections.so
00126000-00127000 rw-p 00005000 08:05 30055
/usr/local/Sage/sage-4.6-linux-32bit-ubuntu_10.04_lts-i686-Linux/local/
l\
ib/python2.6/lib-dynload/_collections.so
00127000-0012e000 r-xp 00000000 08:05 30076
/usr/local/Sage/sage-4.6-linux-32bit-ubuntu_10.04_lts-i686-Linux/local/
l\
ib/python2.6/lib-dynload/itertools.so
0012e000-0012f000 r--p 00006000 08:05 30076
/usr/local/Sage/sage-4.6-linux-32bit-ubuntu_10.04_lts-i686-Linux/local/
l\
ib/python2.6/lib-dynload/itertools.so
0012f000-00132000 rw-p 00007000 08:05 30076
/usr/local/Sage/sage-4.6-linux-32bit-ubuntu_10.04_lts-i686-Linux/local/
l\
ib/python2.6/lib-dynload/itertools.so
00132000-00133000 r-xp 00000000 08:05 30165
/usr/local/Sage/sage-4.6-linux-32bit-ubuntu_10.04_lts-i686-Linux/local/
l\
ib/python2.6/lib-dynload/_weakref.so
00133000-00134000 r--p 00000000 08:05 30165
/usr/local/Sage/sage-4.6-linux-32bit-ubuntu_10.04_lts-i686-Linux/local/
l\
ib/python2.6/lib-dynload/_weakref.so
00134000-00135000 rw-p 00001000 08:05 30165
/usr/local/Sage/sage-4.6-linux-32bit-ubuntu_10.04_lts-i686-Linux/local/
l\
ib/python2.6/lib-dynload/_weakref.so
00135000-00141000 r-xp 00000000 08:05 192736
/usr/local/Sage/sage-4.6-linux-32bit-ubuntu_10.04_lts-i686-Linux/devel/
s\
age-main/build/sage/misc/randstate.so
00141000-00142000 r--p 0000b000 08:05 192736
/usr/local/Sage/sage-4.6-linux-32bit-ubuntu_10.04_lts-i686-Linux/devel/
s\
age-main/build/sage/misc/randstate.so
00142000-0014c000 rw-p 0000c000 08:05 192736
/usr/local/Sage/sage-4.6-linux-32bit-ubuntu_10.04_lts-i686-Linux/devel/
s\
age-main/build/sage/misc/randstate.so
0014c000-0015c000 r-xp 00000000 08:05 199735
/usr/local/Sage/sage-4.6-linux-32bit-ubuntu_10.04_lts-i686-Linux/devel/
s\
age-main/c_lib/libcsage.so
0015c000-0015d000 r--p 0000f000 08:05 199735
/usr/local/Sage/sage-4.6-linux-32bit-ubuntu_10.04_lts-i686-Linux/devel/
s\
age-main/c_lib/libcsage.so
0015d000-0015e000 rw-p 00010000 08:05 199735
/usr/local/Sage/sage-4.6-linux-32bit-ubuntu_10.04_lts-i686-Linux/devel/
s\
age-main/c_lib/libcsage.so
0015e000-00178000 r-xp 00000000 08:05 32695 /lib/libgcc_s.so.1
00178000-00179000 r--p 00019000 08:05 32695 /lib/libgcc_s.so.1
00179000-0017a000 rw-p 0001a000 08:05 32695 /lib/libgcc_s.so.1
0017a000-0018c000 r-xp 00000000 08:05 192836
/usr/local/Sage/sage-4.6-linux-32bit-ubuntu_10.04_lts-i686-Linux/devel/
s\
age-main/build/sage/misc/misc_c.so
0018c000-0018d000 r--p 00011000 08:05 192836
/usr/local/Sage/sage-4.6-linux-32bit-ubuntu_10.04_lts-i686-Linux/devel/
s\
age-main/build/sage/misc/misc_c.so
0018d000-00194000 rw-p 00012000 08:05 192836
/usr/local/Sage/sage-4.6-linux-32bit-ubuntu_10.04_lts-i686-Linux/devel/
s\
age-main/build/sage/misc/misc_c.so
00194000-001ab000 r-xp 00000000 08:05 30072
/usr/local/Sage/sage-4.6-linux-32bit-ubuntu_10.04_lts-i686-Linux/local/
l\
ib/python2.6/lib-dynload/bz2.so
001ab000-001ac000 r--p 00016000 08:05 30072
/usr/local/Sage/sage-4.6-linux-32bit-ubuntu_10.04_lts-i686-Linux/local/
l\
ib/python2.6/lib-dynload/bz2.so
001ac000-001af000 rw-p 00017000 08:05 30072
/usr/local/Sage/sage-4.6-linux-32bit-ubuntu_10.04_lts-i686-Linux/local/
l\
ib/python2.6/lib-dynload/bz2.so
001af000-001cb000 r-xp 00000000 08:05 46306 /lib/ld-2.12.1.so
001cb000-001cc000 r--p 0001b000 08:05 46306 /lib/ld-2.12.1.so
001cc000-001cd000 rw-p 0001c000 08:05 46306 /lib/ld-2.12.1.so
001cd000-00324000 r-xp 00000000 08:05 46342 /lib/libc-2.12.1.so
00324000-00326000 r--p 00157000 08:05 46342 /lib/libc-2.12.1.so
00326000-00327000 rw-p 00159000 08:05 46342 /lib/libc-2.12.1.so
00327000-0032a000 rw-p 00000000 00:00 0
0032a000-0032c000 r-xp 00000000 08:05 30054
/usr/local/Sage/sage-4.6-linux-32bit-ubuntu_10.04_lts-i686-Linux/local/
l\
ib/python2.6/lib-dynload/_random.so
0032c000-0032d000 r--p 00001000 08:05 30054
/usr/local/Sage/sage-4.6-linux-32bit-ubuntu_10.04_lts-i686-Linux/local/
l\
ib/python2.6/lib-dynload/_random.so9

I know nothing about low level programming, yet it does look like an
error somewhere in the compiled part of Python's random(), no?

Many thanks in advance for any pointers, Kees



Volker Braun

unread,
Dec 23, 2010, 6:17:56 AM12/23/10
to sage-s...@googlegroups.com
I'm getting the somewhat expected result:

sage: i=sqrt(-1) 
sage: for k in range(100): 
....:         print k; r1=random(); r2=random() 
....:     try: 
....:             xx=100*r1-i; yy=100*r2 
....:         res=gamma(xx)*gamma(yy)/gamma(xx+yy) 
....:     except: 
....:             pass 
....: 
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
  ***   overflow in t_REAL->double conversion.
17
18
19
20
... and so on...


Try running your code in sage -gdb and then bt (backtrace) the stack.

Since you apparently are running a binary distribution, I'd bet that there is a slight mismatch between the overflow signal handler on your distribution and on the distribution that it was compiled for. So when the overflow occurs it longjmp's into the abyss....


KvS

unread,
Dec 23, 2010, 7:06:07 AM12/23/10
to sage-support
Hi Volker,

I followed your suggestions and this is the output:

#0 0x0012e416 in __kernel_vsyscall ()
#1 0x0030e941 in raise () from /lib/libc.so.6
#2 0x00311e42 in abort () from /lib/libc.so.6
#3 0x00346305 in ?? () from /lib/libc.so.6
#4 0x003c9970 in __fortify_fail () from /lib/libc.so.6
#5 0x003c98da in ?? () from /lib/libc.so.6
#6 0x003c9849 in __longjmp_chk () from /lib/libc.so.6
#7 0x00b49f0e in pari_err (numerr=15) at ../src/language/init.c:980
#8 0x008eef06 in rtodbl (x=0xb7d3d708)
from /usr/local/Sage/sage-4.6-linux-32bit-ubuntu_10.04_lts-i686-
Linux/local/lib/libpari-gmp-2.4.so.3
#9 0x00eab396 in
__pyx_f_4sage_5rings_14complex_double_20ComplexDoubleElement__new_from_gen_c
(__pyx_v_self=0x843932c, __pyx_v_g=0xb7d3d738,
__pyx_v_sp=3084113776) at sage/rings/complex_double.c:6488
#10 0x00ebf6a6 in
__pyx_pf_4sage_5rings_14complex_double_20ComplexDoubleElement_gamma
(__pyx_v_self=0x843932c, unused=0x0) at sage/rings/complex_double.c:
12513
#11 0x0019cc81 in PyCFunction_Call (func=0x824732c, arg=0xb7fa502c,
kw=0x0)
at Objects/methodobject.c:90
#12 0x0015973c in PyObject_Call (func=0x824732c, arg=0xb7fa502c,
kw=0x0)
at Objects/abstract.c:2492
#13 0x0392f1c3 in py_tgamma (__pyx_v_x=0x843932c)
at sage/symbolic/pynac.cpp:9137
#14 0x03ad7169 in GiNaC::Number_T::tgamma (this=0xa6da6f4) at
numeric.cpp:1280
#0 0x0012e416 in __kernel_vsyscall ()
#1 0x0030e941 in raise () from /lib/libc.so.6
#2 0x00311e42 in abort () from /lib/libc.so.6
#3 0x00346305 in ?? () from /lib/libc.so.6
#4 0x003c9970 in __fortify_fail () from /lib/libc.so.6
#5 0x003c98da in ?? () from /lib/libc.so.6
#6 0x003c9849 in __longjmp_chk () from /lib/libc.so.6
#7 0x00b49f0e in pari_err (numerr=15) at ../src/language/init.c:980
#8 0x008eef06 in rtodbl (x=0xb7d3d708)
from /usr/local/Sage/sage-4.6-linux-32bit-ubuntu_10.04_lts-i686-
Linux/local/lib/libpari-gmp-2.4.so.3
#9 0x00eab396 in
__pyx_f_4sage_5rings_14complex_double_20ComplexDoubleElement__new_from_gen_c
(__pyx_v_self=0x843932c, __pyx_v_g=0xb7d3d738,
__pyx_v_sp=3084113776) at sage/rings/complex_double.c:6488
#10 0x00ebf6a6 in
__pyx_pf_4sage_5rings_14complex_double_20ComplexDoubleElement_gamma
(__pyx_v_self=0x843932c, unused=0x0) at sage/rings/complex_double.c:
12513
#11 0x0019cc81 in PyCFunction_Call (func=0x824732c, arg=0xb7fa502c,
kw=0x0)
at Objects/methodobject.c:90
#12 0x0015973c in PyObject_Call (func=0x824732c, arg=0xb7fa502c,
kw=0x0)
at Objects/abstract.c:2492
#13 0x0392f1c3 in py_tgamma (__pyx_v_x=0x843932c)
at sage/symbolic/pynac.cpp:9137
#14 0x03ad7169 in GiNaC::Number_T::tgamma (this=0xa6da6f4) at
numeric.cpp:1280
#0 0x0012e416 in __kernel_vsyscall ()
#1 0x0030e941 in raise () from /lib/libc.so.6
#2 0x00311e42 in abort () from /lib/libc.so.6
#3 0x00346305 in ?? () from /lib/libc.so.6
#4 0x003c9970 in __fortify_fail () from /lib/libc.so.6
#5 0x003c98da in ?? () from /lib/libc.so.6
#6 0x003c9849 in __longjmp_chk () from /lib/libc.so.6
#7 0x00b49f0e in pari_err (numerr=15) at ../src/language/init.c:980
#8 0x008eef06 in rtodbl (x=0xb7d3d708)
from /usr/local/Sage/sage-4.6-linux-32bit-ubuntu_10.04_lts-i686-
Linux/local/lib/libpari-gmp-2.4.so.3
#9 0x00eab396 in
__pyx_f_4sage_5rings_14complex_double_20ComplexDoubleElement__new_from_gen_c
(__pyx_v_self=0x843932c, __pyx_v_g=0xb7d3d738,
__pyx_v_sp=3084113776) at sage/rings/complex_double.c:6488
#10 0x00ebf6a6 in
__pyx_pf_4sage_5rings_14complex_double_20ComplexDoubleElement_gamma
(__pyx_v_self=0x843932c, unused=0x0) at sage/rings/complex_double.c:
12513
#11 0x0019cc81 in PyCFunction_Call (func=0x824732c, arg=0xb7fa502c,
kw=0x0)
at Objects/methodobject.c:90
#12 0x0015973c in PyObject_Call (func=0x824732c, arg=0xb7fa502c,
kw=0x0)
at Objects/abstract.c:2492
#13 0x0392f1c3 in py_tgamma (__pyx_v_x=0x843932c)
at sage/symbolic/pynac.cpp:9137
#14 0x03ad7169 in GiNaC::Number_T::tgamma (this=0xa6da6f4) at
numeric.cpp:1280
#15 0x03ad93a2 in GiNaC::tgamma (x=...) at numeric.cpp:2380
#16 0x03a71212 in GiNaC::tgamma_eval (x=...) at inifcns_gamma.cpp:186
#17 0x03a184e6 in GiNaC::function::eval (this=0xbfffdadc, level=1)
at function.cpp:796
#18 0x03a016ba in GiNaC::ex::construct_from_basic (other=...) at
ex.cpp:312
#19 0x03d238ad in ex (__pyx_v_self=0xaa0ed8c, __pyx_args=0xb7fa502c,
__pyx_kwds=0x0)
at /home/wstein/build/sage-4.6/local//include/pynac/ex.h:266
#20 __pyx_pf_4sage_8symbolic_10expression_10Expression_gamma (
__pyx_v_self=0xaa0ed8c, __pyx_args=0xb7fa502c, __pyx_kwds=0x0)
at sage/symbolic/expression.cpp:22628
#21 0x0019cc48 in PyCFunction_Call (func=0xa97cdcc, arg=0xb7fa502c,
kw=0x0)
at Objects/methodobject.c:85
#22 0x0015973c in PyObject_Call (func=0xa97cdcc, arg=0xb7fa502c,
kw=0x0)
at Objects/abstract.c:2492
#23 0x03db43c8 in
__pyx_pf_4sage_8symbolic_8function_13GinacFunction___call__ (
__pyx_v_self=0x9c053ac, __pyx_args=0x855cf0c,
__pyx_kwds=0xaa113e4)
at sage/symbolic/function.cpp:6553
#24 0x001b4c6d in wrap_call (self=0x9c053ac, args=0x855cf0c,
wrapped=0x3db3d00, kwds=0xaa113e4) at Objects/typeobject.c:4591
#25 0x001755b0 in wrapper_call (wp=0xa9e308c, args=0x855cf0c,
kwds=0x6)
at Objects/descrobject.c:982
#26 0x0015973c in PyObject_Call (func=0xa9e308c, arg=0x855cf0c,
kw=0xaa113e4)

I am running Ubuntu 10.10 btw. Can we/you/I deduce something from the
above?

Many thanks, Kees

Volker Braun

unread,
Dec 23, 2010, 7:25:59 AM12/23/10
to sage-s...@googlegroups.com
My guess would be

#8  0x008eef06 in rtodbl (x=0xb7d3d708) 

This is where the over flow occurs, raises signal

#7  0x00b49f0e in pari_err (numerr=15) at ../src/language/init.c:980 

it is handled by the pari error handler, which attempts to longjmp back into rtodbl or some cleanup routine (did anyone forget to setjmp the target?) 

#6  0x003c9849 in __longjmp_chk () from /lib/libc.so.6 

the libc is nice enough to do some sanity checking before you longjmp into nirvana 

#4  0x003c9970 in __fortify_fail () from /lib/libc.so.6 
#5  0x003c98da in ?? () from /lib/libc.so.6 

Something is broken!

Bottom line: compile your own Sage.

KvS

unread,
Dec 23, 2010, 9:30:13 AM12/23/10
to sage-support
Thanks a lot for your efforts Volker! I have no experience with
compiling code, but I will give it a go.

Should we report this somewhere, or is this just an inherent problem
with running precompiled binaries?

Cheers, Kees

Volker Braun

unread,
Dec 23, 2010, 10:23:35 AM12/23/10
to sage-s...@googlegroups.com
Unless you are running precisely 32bit ubuntu 10.04 lts there is nothing that Sage can do about it.
Reply all
Reply to author
Forward
0 new messages