[Numpy-discussion] segmentation fault

Keith Goodman kwgoodman@gmail....
Wed May 28 15:49:27 CDT 2008


On Wed, May 28, 2008 at 1:16 PM, Keith Goodman <kwgoodman@gmail.com> wrote:
> On Wed, May 28, 2008 at 1:06 PM, Alan McIntyre <alan.mcintyre@gmail.com> wrote:
>> On Wed, May 28, 2008 at 3:34 PM, Charles R Harris
>> <charlesr.harris@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