[NumPy-Tickets] [NumPy] #2046: Deleting ndarray.real on an instance segfaults

NumPy Trac numpy-tickets@scipy....
Sun Feb 12 18:37:20 CST 2012


#2046: Deleting ndarray.real on an instance segfaults
-------------------------+--------------------------------------------------
 Reporter:  alex_gaynor  |       Owner:  somebody   
     Type:  defect       |      Status:  new        
 Priority:  normal       |   Milestone:  Unscheduled
Component:  Other        |     Version:  devel      
 Keywords:               |  
-------------------------+--------------------------------------------------

Old description:

> Tested on the latest numpy master from github:
>
> {{{
> (e268cfc7-ff3f-4d97-a02c-27481c8a8186)alex@alex-gaynor-
> laptop:~/.virtualenvs/e268cfc7-ff3f-4d97-a02c-27481c8a8186$ python
> Python 2.7.2+ (default, Oct  4 2011, 20:06:09)
> [GCC 4.6.1] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
> >>> import numpy
> >>> del numpy.arange(5).real
> Segmentation fault
>
> }}}

New description:

 Tested on the latest numpy master from github:

 {{{
 (e268cfc7-ff3f-4d97-a02c-27481c8a8186)alex@alex-gaynor-
 laptop:~/.virtualenvs/e268cfc7-ff3f-4d97-a02c-27481c8a8186$ python
 Python 2.7.2+ (default, Oct  4 2011, 20:06:09)
 [GCC 4.6.1] on linux2
 Type "help", "copyright", "credits" or "license" for more information.
 >>> import numpy
 >>> del numpy.arange(5).real
 Segmentation fault

 }}}

 Note that if a getter isn't used we get


 {{{
 In [3]: del ones(3)
   File "<ipython-input-3-b548f34f731a>", line 1
 SyntaxError: can't delete function call (<ipython-input-3-b548f34f731a>,
 line 1)


 In [4]: del ones(3).view(double)
   File "<ipython-input-4-6d0dbe42344e>", line 1
 SyntaxError: can't delete function call (<ipython-input-4-6d0dbe42344e>,
 line 1)

 }}}

 which is a strange message. But it looks like this might almost be
 considered a Python bug where python del can't recognize getters/setters.

--

Comment(by charris):

 This seems to be a problem with getter functions returning writable
 objects:


 {{{
 In [5]: del ones(2).base
 ---------------------------------------------------------------------------
 AttributeError                            Traceback (most recent call
 last)
 /home/charris/<ipython-input-5-f9c0ca6fc60a> in <module>()
 ----> 1 del ones(2).base

 AttributeError: attribute 'base' of 'numpy.ndarray' objects is not
 writable

 In [6]: del ones(2).dtype
 Segmentation fault (core dumped)

 }}}

 I'm guessing this is a reference counting problem.

-- 
Ticket URL: <http://projects.scipy.org/numpy/ticket/2046#comment:2>
NumPy <http://projects.scipy.org/numpy>
My example project


More information about the NumPy-Tickets mailing list