[Numpy-discussion] Segmentation fault with argsort

Charles R Harris charlesr.harris@gmail....
Fri Dec 18 15:28:08 CST 2009


On Fri, Dec 18, 2009 at 2:02 PM, Charles R Harris <charlesr.harris@gmail.com
> wrote:

>
>
> On Fri, Dec 18, 2009 at 10:46 AM, Keith Goodman <kwgoodman@gmail.com>wrote:
>
>> I am using the numpy 1.3 binary from Ubuntu 9.10. Is this already
>> known, fixed, reproducible?
>>
>> >> np.array(121).argsort(0).argsort(0)
>> Segmentation fault
>>
>>
> The immediate problem is in scalartypes.c.src in these lines
>
>     {"sort",
>         (PyCFunction)gentype_sort,
>         METH_VARARGS, NULL},
>     {"argsort",
>         (PyCFunction)gentype_argsort,
>         METH_VARARGS, NULL},
>
> But the methods array_{argsort, sort} take keywords and are called that
> way. The following version fixes things, but I am not sure it is the correct
> fix, the gentype_* functions may need to be fixed instead.
>
>     {"sort",
>         (PyCFunction)gentype_sort,
>         METH_VARARGS|METH_KEYWORDS, NULL},
>     {"argsort",
>         (PyCFunction)gentype_argsort,
>         METH_VARARGS|METH_KEYWORDS, NULL},
>
>
Changing the generated function gentype_argsort to  pass NULL for the
keyword argument also fixes the problem. This may be the correct fix, but in
terms of avoiding special cases it may be better to have it take the normal
run of keywords. Note that view doesn't take keywords so a dtype can't be
passed, making it kind of useless. I think the whole method section for
types could use an audit.

Chuck
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20091218/7b776ce6/attachment.html 


More information about the NumPy-Discussion mailing list