[Numpy-tickets] [NumPy] #277: memory error in assignment to flat object array

NumPy numpy-tickets at scipy.net
Thu Sep 14 08:20:15 CDT 2006


#277: memory error in assignment to flat object array
------------------------+---------------------------------------------------
 Reporter:  stefan      |       Owner:  somebody   
     Type:  defect      |      Status:  new        
 Priority:  normal      |   Milestone:  1.0 Release
Component:  numpy.core  |     Version:  devel      
 Severity:  normal      |    Keywords:             
------------------------+---------------------------------------------------
 Neilen Marais notified me of this problem in r3154.  The following snippet
 tries to assign an invalid value to a flattened object array:

 {{{
 import numpy as N
 x = N.zeros((2,2),dtype=object)
 x.flat = []
 }}}

 which results in the following errors under Valgrind:

 {{{
 ==22358== Invalid read of size 4
 ==22358==    at 0x450F750: array_flat_set (arrayobject.c:161)
 ==22358==    by 0x807DDE1: PyObject_GenericSetAttr (in /usr/bin/python2.4)
 ==22358==    by 0x807D4C3: PyObject_SetAttr (in /usr/bin/python2.4)
 ==22358==    by 0x80B37FA: PyEval_EvalFrame (in /usr/bin/python2.4)
 ==22358==    by 0x80B771E: PyEval_EvalCodeEx (in /usr/bin/python2.4)
 ==22358==    by 0x80B7964: PyEval_EvalCode (in /usr/bin/python2.4)
 ==22358==    by 0x80D94CB: PyRun_FileExFlags (in /usr/bin/python2.4)
 ==22358==    by 0x80D976B: PyRun_SimpleFileExFlags (in /usr/bin/python2.4)
 ==22358==    by 0x8055B32: Py_Main (in /usr/bin/python2.4)
 ==22358==    by 0x4082EA1: __libc_start_main (in
 /lib/tls/i686/cmov/libc-2.3.6.so)
 ==22358==  Address 0x5B152BC is 0 bytes after a block of size 4 alloc'd
 ==22358==    at 0x401C422: malloc (vg_replace_malloc.c:149)
 ==22358==    by 0x44F42D1: PyArray_NewFromDescr (arrayobject.c:5299)
 ==22358==    by 0x450E216: PyArray_FromAny (arrayobject.c:7227)
 ==22358==    by 0x450EE9B: array_flat_set (arrayobject.c:6468)
 ==22358==    by 0x807DDE1: PyObject_GenericSetAttr (in /usr/bin/python2.4)
 ==22358==    by 0x807D4C3: PyObject_SetAttr (in /usr/bin/python2.4)
 ==22358==    by 0x80B37FA: PyEval_EvalFrame (in /usr/bin/python2.4)
 ==22358==    by 0x80B771E: PyEval_EvalCodeEx (in /usr/bin/python2.4)
 ==22358==    by 0x80B7964: PyEval_EvalCode (in /usr/bin/python2.4)
 ==22358==    by 0x80D94CB: PyRun_FileExFlags (in /usr/bin/python2.4)
 ==22358==
 ==22358== Invalid read of size 1
 ==22358==    at 0x401E24D: memmove (mac_replace_strmem.c:486)
 ==22358==    by 0x450F112: array_flat_set (arrayobject.c:6482)
 ==22358==    by 0x807DDE1: PyObject_GenericSetAttr (in /usr/bin/python2.4)
 ==22358==    by 0x807D4C3: PyObject_SetAttr (in /usr/bin/python2.4)
 ==22358==    by 0x80B37FA: PyEval_EvalFrame (in /usr/bin/python2.4)
 ==22358==    by 0x80B771E: PyEval_EvalCodeEx (in /usr/bin/python2.4)
 ==22358==    by 0x80B7964: PyEval_EvalCode (in /usr/bin/python2.4)
 ==22358==    by 0x80D94CB: PyRun_FileExFlags (in /usr/bin/python2.4)
 ==22358==    by 0x80D976B: PyRun_SimpleFileExFlags (in /usr/bin/python2.4)
 ==22358==    by 0x8055B32: Py_Main (in /usr/bin/python2.4)
 ==22358==  Address 0x5B152BC is 0 bytes after a block of size 4 alloc'd
 ==22358==    at 0x401C422: malloc (vg_replace_malloc.c:149)
 ==22358==    by 0x44F42D1: PyArray_NewFromDescr (arrayobject.c:5299)
 ==22358==    by 0x450E216: PyArray_FromAny (arrayobject.c:7227)
 ==22358==    by 0x450EE9B: array_flat_set (arrayobject.c:6468)
 ==22358==    by 0x807DDE1: PyObject_GenericSetAttr (in /usr/bin/python2.4)
 ==22358==    by 0x807D4C3: PyObject_SetAttr (in /usr/bin/python2.4)
 ==22358==    by 0x80B37FA: PyEval_EvalFrame (in /usr/bin/python2.4)
 ==22358==    by 0x80B771E: PyEval_EvalCodeEx (in /usr/bin/python2.4)
 ==22358==    by 0x80B7964: PyEval_EvalCode (in /usr/bin/python2.4)
 ==22358==    by 0x80D94CB: PyRun_FileExFlags (in /usr/bin/python2.4)
 ==22358==
 }}}

-- 
Ticket URL: <http://projects.scipy.org/scipy/numpy/ticket/277>
NumPy <http://projects.scipy.org/scipy/numpy>
The fundamental package needed for scientific computing with Python.


More information about the Numpy-tickets mailing list