[SciPy-dev] Segfault with newcore
Ed Schofield
schofield at ftw.at
Thu Nov 17 09:34:01 CST 2005
Ed Schofield wrote:
>The following gives a segfault
>
>
>
>>>>a = array([1.,2.])
>>>>a['BLAH'] = 1
>>>>
>>>>
Hi Travis,
Well done for fixing this.
More segfaults from the crazy input department:
Case (a)
>>> a = scipy.array([1,2,3,4])
>>> b = xrange(3)
>>> a[b]
Segmentation fault.
Case (b)
>>> a = scipy.array([1,2,3,4])
>>> b = scipy.sparse.dok_matrix((5,5))
>>> a[b]
Segmentation fault.
Case (c)
>>> a = scipy.array([1,2,3,4])
>>> b = array.array('d',[1,2])
>>> a[b]
Segmentation fault.
Case (c) causes a segfault in a different part of the code to the other two.
I'm not sure what we should aim to return in these cases, but we
probably want to return
IndexError: index must be either an int or a sequence
for the first two but make case (c) return the same result as a[[1,2]].
I haven't tested a[numarray], a[newnumeric], or a[pre_24.0_numeric], but
these might die too...
Another, more trivial, observation:
Case (d)
>>> a = scipy.arange(10)
>>> a[0.9]
0
>>> a[-1.9]
9
So float indices are rounded towards zero. Should we raise the same
IndexError here? This would be consistent with the wording of the
exception :) It might be safer, at least whenever int(floatindex) !=
floatindex. Or perhaps there's a use case for this that I'm missing ...
-- Ed
---------------------------
Backtraces:
(a) and (c)
[Switching to Thread -1208559936 (LWP 6393)]
[Switching to Thread -1208822080 (LWP 21200)]
0xb7d24350 in PyArray_MapIterReset (mit=0x83a3df8) at arrayobject.c:6791
6791 copyswap = mit->iters[0]->ao->descr->copyswap;
(gdb) bt
#0 0xb7d64350 in PyArray_MapIterReset (mit=0x8210c60) at arrayobject.c:6791
#1 0xb7d52a13 in PyArray_GetMap (mit=0x8210c60) at arrayobject.c:1587
#2 0xb7d532df in array_subscript (self=0x8206700, op=0xb7f2db90)
at arrayobject.c:1722
#3 0xb7d537c3 in array_subscript_nice (self=0x8206700, op=0xb7f2db90)
at arrayobject.c:1841
#4 0x080594f4 in PyObject_GetItem (o=0x8206700, key=0xb7f2db90)
at Objects/abstract.c:94
(b)
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread -1208465728 (LWP 21285)]
0x0808e582 in PyType_IsSubtype (a=0x3ff00000, b=0xb7d92820)
at Objects/typeobject.c:821
821 if (!(a->tp_flags & Py_TPFLAGS_HAVE_CLASS))
(gdb) bt
#0 0x0808e582 in PyType_IsSubtype (a=0x3ff00000, b=0xb7d92820)
at Objects/typeobject.c:821
#1 0xb7d776e0 in array_fromobject (op=0x83ade88, typecode=0xbfb97dbc,
min_depth=0, max_depth=0, flags=16) at arrayobject.c:5615
#2 0xb7d77b0c in PyArray_FromAny (op=0x83ade88, typecode=0xbfb97dbc,
min_depth=0, max_depth=0, requires=16) at arrayobject.c:5772
#3 0xb7d7af4d in _convert_obj (obj=0x83ade88, iter=0xbfb97e04)
at arrayobject.c:6697
#4 0xb7d7d02e in PyArray_MapIterNew (indexobj=0xb6214ca0)
at arrayobject.c:7207
#5 0xb7d6a29b in array_subscript (self=0x83a45c0, op=0xb6214ca0)
at arrayobject.c:1718
#6 0xb7d6a7c3 in array_subscript_nice (self=0x83a45c0, op=0xb6214ca0)
at arrayobject.c:1841
More information about the Scipy-dev
mailing list