[Numpy-discussion] segmentation fault

Keith Goodman kwgoodman at gmail.com
Wed May 28 16:49:27 EDT 2008


On Wed, May 28, 2008 at 1:16 PM, Keith Goodman <kwgoodman at gmail.com> wrote:
> On Wed, May 28, 2008 at 1:06 PM, Alan McIntyre <alan.mcintyre at gmail.com> wrote:
>> On Wed, May 28, 2008 at 3:34 PM, Charles R Harris
>> <charlesr.harris at gmail.com> wrote:
>>>> I wonder if this is something that ought to be looked at for all
>>>> functions with an "out" parameter?  ndarray.compress also had problems
>>>> with array type mismatch (#789); I can't imagine that it's safe to
>>>> assume only these two functions were doing it incorrectly. (Unless of
>>>> course somebody has recently looked at all of them)
>>>
>>> I think that is an excellent idea! A good start would be to list all the
>>> functions with the out parameter and then write some tests. The current
>>> behavior is inconsistent and we not only need to specify the behavior, but
>>> fix all the places that don't follow the rules.
>>
>> There's a ticket (#416) that calls for the docstrings of such
>> functions to be updated as well; that's something that should be easy
>> to do at the same time.  Since I'm working on tests nowadays, I'll see
>> if I can work on coming up with a list and at least writing some
>> tests.
>
> I guess cumprod is an obvious one to try:
>
>>> def fn():
>   x = np.random.rand(5,2)
>   x.cumprod(None, out=x)
>   return x
>
>   ....:
>>> fn()
> Segmentation fault

Are there any guarantees that the overwritten memory belongs to numpy
so that the segfault cleans up its own mess?



More information about the NumPy-Discussion mailing list