[Numpy-discussion] numpy record array segfault

Sameer DCosta sameerslists at gmail.com
Tue Feb 19 18:10:10 EST 2008


Hi,

I'm getting a segfault when using python objects with record arrays.
The code (below) basically assigns a single datetime object to a slice
of a column in the record array and then python segfaults as soon as I
try to access those array values. I'm using the latest svn version of
numpy compiled with gcc 3.4.1 on Solaris (intel). Any ideas why this
is happening? A reference counting problem maybe? Thanks for taking a
look.

Sameer

johnh at flag:~> gcc --version
gcc (GCC) 3.4.1
Copyright (C) 2004 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

johnh at flag:~> uname -a
SunOS flag 5.10 Generic_118855-15 i86pc i386 i86pc
johnh at flag:~> python -V
Python 2.4.2
johnh at flag:~> cat tmp.py
import datetime
import numpy as np

print np.__version__

def myfunc(N):
   newrec = np.empty(N, dtype=[('date', '|O4'), ('age', int)])
   newrec['date'] = datetime.date(2002,1,1)
   newrec['age'] = 22


   newrec['date'][1:12] = datetime.date(2003,1,1)
   return newrec.view(np.recarray)


if __name__=='__main__':
   newrec = myfunc(29)
   print newrec['date']

johnh at flag:~> python ~/tmp.py
1.0.5.dev4812
Segmentation Fault (core dumped)



More information about the NumPy-Discussion mailing list