[PYTHON MATRIX-SIG] Another way to crash the interpreter using long ints...

tim@lassi.ece.uiuc.edu tim@lassi.ece.uiuc.edu
Tue, 20 Aug 1996 09:18:18 -0500


I've been trying to look into it from this end, unfortunatley, my
understanding of the python internals is somewhat (ok very)
sketchy. For what its worth, here's what I've noticed:

1) Long ints work most of the time on alpha2:

>>> arange(1,5l,2)
1L 3L
>>> arange(1,5l)[::2]
1L 3L

Concatenating arrays of long ints is the only thing that I've found
that breaks on my machine.

2) I've inluded the stack trace for:
> >>> from Numeric import *
> >>> c = concatenate((arange(1l,5l),))
> >>> c.shape
> (4,)
> >>> c
> Segmentation fault

Way down at the bottom for what it's worth. Poking around the only
thing that looked obviously wrong (recall I know little about the guts
of python) was that in builtin_str, it's passed a tuple with
ob_refcnt=3, and this gets passed to newgetargs which returns what
seems to be garbage:

	if (!newgetargs(args, "O:str", &v))
		return NULL;
	return strobject(v);

(gdb) p *v->ob_type
$20 = {ob_refcnt = 135100992, ob_type = 0x80d7a20, ob_size = 65537,  
                   ^^^^^^^^^
tp_name = 0x80d7a40 "Tpz\r\b`z\r\b\001", tp_basicsize = 0,  <ETC....>
                     ^^^^^^^^^^^^^^^^^
 
3) This also breaks the interpreter, and I don't think it calls the
array printing code. It does have that same goofy object floating
around though...

That's all I can think of, for now.

-tim


#0  0x80d78e0 in UP ()
#1  0x806ea2b in PyObject_Str (v=0x80d7a40) at object.c:231
#2  0x8040cc9 in builtin_str (self=0x0, args=0x80d1380)
    at bltinmodule.c:1386
#3  0x8047b1d in call_builtin (func=0x80a6d40, arg=0x80d1380, 
    kw=0x0) at ceval.c:2401
#4  0x80479a1 in PyEval_CallObjectWithKeywords (func=0x80a6d40, 
    arg=0x80d1380, kw=0x0) at ceval.c:2366
#5  0x80458c1 in eval_code2 (co=0x80cc580, globals=0x80d7f80, 
    locals=0x0, args=0x80d156c, argcount=1, kws=0x0, kwcount=0, 
    defs=0x0, defcount=0, owner=0x0) at ceval.c:1629
#6  0x8047fcd in call_function (func=0x80ca0c0, arg=0x80d1560, 
    kw=0x0) at ceval.c:2518
#7  0x8047981 in PyEval_CallObjectWithKeywords (func=0x80ca0c0, 
    arg=0x80d1560, kw=0x0) at ceval.c:2364
#8  0x8047862 in PyEval_CallObject (func=0x80ca0c0, arg=0x80d1560)
    at ceval.c:2335
#9  0x803f0fd in builtin_map (self=0x0, args=0x80ceba0)
    at bltinmodule.c:676
#10 0x8047b1d in call_builtin (func=0x80a6e30, arg=0x80ceba0, 
    kw=0x0) at ceval.c:2401
#11 0x80479a1 in PyEval_CallObjectWithKeywords (func=0x80a6e30, 
    arg=0x80ceba0, kw=0x0) at ceval.c:2366
#12 0x80458c1 in eval_code2 (co=0x80cc240, globals=0x80d7f80, 
    locals=0x0, args=0x80d79cc, argcount=1, kws=0x0, kwcount=0, 
    defs=0x80c63ec, defcount=3, owner=0x0) at ceval.c:1629
#13 0x8047fcd in call_function (func=0x80d7ee0, arg=0x80d79c0, 
    kw=0x0) at ceval.c:2518
#14 0x8047981 in PyEval_CallObjectWithKeywords (func=0x80d7ee0, 
    arg=0x80d79c0, kw=0x0) at ceval.c:2364
#15 0x8047862 in PyEval_CallObject (func=0x80d7ee0, arg=0x80d79c0)
    at ceval.c:2335
#16 0x800dc55 in array_print (self=0x80d6940, fp=0x809fa90, flags=0)
    at ./arrayobject.c:1037
#17 0x806e877 in PyObject_Print (op=0x80d6940, fp=0x809fa90, 
    flags=0) at object.c:190
#18 0x8063841 in PyFile_WriteObject (v=0x80d6940, f=0x80a53e0, 
    flags=0) at fileobject.c:793
#19 0x80436d4 in eval_code2 (co=0x80d6980, globals=0x80ad820, 
    locals=0x80ad820, args=0x0, argcount=0, kws=0x0, kwcount=0, 
    defs=0x0, defcount=0, owner=0x0) at ceval.c:894
#20 0x80419a2 in PyEval_EvalCode (co=0x80d6980, globals=0x80ad820, 
    locals=0x80ad820) at ceval.c:282
#21 0x8058021 in run_node (n=0x80d7880, 
    filename=0x808a8aa "<stdin>", globals=0x80ad820, 
    locals=0x80ad820) at pythonrun.c:426
#22 0x8057766 in PyRun_InteractiveOne (fp=0x809fb50, 
    filename=0x808a8aa "<stdin>") at pythonrun.c:208
#23 0x805754f in PyRun_InteractiveLoop (fp=0x809fb50, 
    filename=0x808a8aa "<stdin>") at pythonrun.c:149
#24 0x805740a in PyRun_AnyFile (fp=0x809fb50, 
    filename=0x808a8aa "<stdin>") at pythonrun.c:126
#25 0x80035b8 in main (argc=1, argv=0xbffffd30) at main.c:207
#26 0x8003075 in ___crt_dummy__ ()
#27 0xbffffbb8 in UP ()
#28 0x2fc45 in ?? ()

--
	-tim

+--------------------------------------------------------------------+
| Tim Hochberg               Ultrahigh Speed Digital Electronics Lab |
| tim@lassi.ece.uiuc.edu              University of Illinois         |
| http://dogbert.ece.uiuc.edu/~tim         (217) 333-6014            |
+--------------------------------------------------------------------+

=================
MATRIX-SIG  - SIG on Matrix Math for Python

send messages to: matrix-sig@python.org
administrivia to: matrix-sig-request@python.org
=================