-
-
Notifications
You must be signed in to change notification settings - Fork 12.2k
Segfault when using recarray 'O' entries (Trac #877) #1475
Description
Original ticket http://projects.scipy.org/numpy/ticket/877 on 2008-08-06 by @mdboom, assigned to unknown.
(This bug report began on the mailing list here: http://projects.scipy.org/pipermail/numpy-discussion/2008-July/035998.html)
I've run into a segfault that occurs in the array destructor with arrays containing object references (type 'O') that have both names and titles.
When a field contains both and name and a title, the fields dictionary contains two entries for that field. This means that the array item destructor (which iterates through the fields dictionary) will decref the pointed-to object twice. If the first decref causes the object to be deleted, the second decref has the potential to segfault.
It seems the simplest patch is to set the object pointer to NULL after decref'ing, so the second decref will do nothing. However, perhaps there is a way to avoid decref'ing twice in the first place.
I've attached a script that exercises the segfault, a gdb backtrace, and a patch. You may need to adjust the number of rows until it is high enough to create a segfault on your system.
This is on:
RHEL4
Python 2.5.2
Numpy SVN r5497