[Numpy-discussion] numpy record array segfault

Sameer DCosta sameerslists@gmail....
Tue Feb 19 17:10:10 CST 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@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@flag:~> uname -a
SunOS flag 5.10 Generic_118855-15 i86pc i386 i86pc
johnh@flag:~> python -V
Python 2.4.2
johnh@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@flag:~> python ~/tmp.py
1.0.5.dev4812
Segmentation Fault (core dumped)


More information about the Numpy-discussion mailing list