Segmentation faults using threads

John Nagle nagle at animats.com
Wed Feb 14 15:12:10 EST 2007


Mathias wrote:
>>
>>     What module are you using for SSH?
>>
>>     What's in your program that isn't pure Python?
>> The problem is probably in some non-Python component; you shouldn't
>> be able to force a memory protection error from within Python code.
>>
> 
> It looks like the error could be in scipy/Numeric, when a large array's 
> type is changed, like this:
> 
>  >>> from scipy import *
>  >>> a=zeros(100000000,'b')    #100 MiB
>  >>> b=a.copy().astype('d')      #800 MiB, ok
>  >>> a=zeros(1000000000,'b')    #1GiB
>  >>> b=a.copy().astype('d')      #8GiB, fails with sf
> Segmentation fault
> 
> if I use zeros directly for allocation of the doubles it works as expected:
> 
>  >>> from scipy import *
>  >>> a=zeros(1000000000,'d')    #8GiB, fails with python exception
> Traceback (most recent call last):
>   File "<stdin>", line 1, in ?
> MemoryError: can't allocate memory for array
>  >>>
> 
> I use python 2.4, but my scipy and Numeric aren't quite up-to-date: 
> scipy version 0.3.2, Numeric v 24.2

    That sounds like the case where the array has to be reallocated from
4-byte floats to 8-byte doubles is being botched.

Take a look at 
"http://www.mail-archive.com/numpy-discussion@lists.sourceforge.net/msg02033.html"

and then at array_cast in arrraymethods.c of scipy.  There may be a
reference count bug in that C code.  I'm not familiar enough with
Python reference count internals to be sure, though.

					John Nagle



More information about the Python-list mailing list