[Numpy-discussion] segfault on searchsorted (1.6.2.dev-396dbb9)

Charles R Harris charlesr.harris@gmail....
Tue Jan 17 10:53:37 CST 2012


On Tue, Jan 17, 2012 at 8:57 AM, Adam Klein <adam@lambdafoundry.com> wrote:

> Hello,
>
> I get a segfault here:
>
> In [1]: x = np.array([1,2,3], dtype='M')
> In [2]: x.searchsorted(2, side='left')
>
> But it's fine here:
>
> In [1]: x = np.array([1,2,3], dtype='M')
> In [2]: x.view('i8').searchsorted(2, side='left')
> Out[2]: 1
>
> This segfaults again:
>
> x.view('i8').searchsorted(np.datetime64(2), side='left')
>
> GDB gets me this far:
>
> Program received signal SIGSEGV, Segmentation fault.
> PyArray_SearchSorted (op1=0x1b8dd70, op2=0x17dfac0, side=NPY_SEARCHLEFT)
> at numpy/core/src/multiarray/item_selection.c:1463
> 1463        Py_INCREF(dtype);
>
>
>
Confirmed in current development. Note that things have changed and the
initial array creation will fail (no unit). The searchsorted will work if
searching for a datetime:

In [10]: x = np.array([1,2,3], 'datetime64[D]')

In [11]: x.searchsorted(datetime64(2,'D'))
Out[11]: 1

So the failure is one of raising an appropriate error message.

Please open a ticket.

Chuck
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20120117/6ab37a02/attachment.html 


More information about the NumPy-Discussion mailing list