[Numpy-discussion] numpy record array segfault
Sameer DCosta
sameerslists at gmail.com
Wed Feb 20 10:47:56 EST 2008
On Wed, Feb 20, 2008 at 1:22 AM, Nils Wagner
<nwagner at iam.uni-stuttgart.de> wrote:
>
> On Tue, 19 Feb 2008 17:10:10 -0600
> "Sameer DCosta" <sameerslists at gmail.com> wrote:
> > 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)
> > _______________________________________________
> > Numpy-discussion mailing list
> > Numpy-discussion at scipy.org
> > http://projects.scipy.org/mailman/listinfo/numpy-discussion
>
>
> No problem here
>
> python tmp.py
> 1.0.5.dev4811
> [2002-01-01 2003-01-01 2003-01-01 2003-01-01 2003-01-01
> 2003-01-01
> 2003-01-01 2003-01-01 2003-01-01 2003-01-01 2003-01-01
> 2003-01-01
> 2002-01-01 2002-01-01 2002-01-01 2002-01-01 2002-01-01
> 2002-01-01
> 2002-01-01 2002-01-01 2002-01-01 2002-01-01 2002-01-01
> 2002-01-01
> 2002-01-01 2002-01-01 2002-01-01 2002-01-01 2002-01-01]
>
> Can you send a backtrace (gdb) ?
>
> Nils
> _______________________________________________
> Numpy-discussion mailing list
> Numpy-discussion at scipy.org
> http://projects.scipy.org/mailman/listinfo/numpy-discussion
>
Thanks for taking a look Nils. Can you try with a larger array (change
the value of N from 29 to 2900)? I have attached the backtrace below.
Program terminated with signal 11, Segmentation fault.
#0 PyObject_Malloc (nbytes=24) at ../Objects/obmalloc.c:605
warning: Source file is more recent than executable.
605 if ((pool->freeblock = *(block **)bp) != NULL) {
(gdb) backtrace
#0 PyObject_Malloc (nbytes=24) at ../Objects/obmalloc.c:605
#1 0x08084eee in _PyObject_New (tp=0x8154980) at ../Objects/object.c:188
#2 0x0810a3f2 in range_iter (seq=0x841b676) at ../Objects/rangeobject.c:266
#3 0x08064d32 in PyObject_GetIter (o=0x841b676) at ../Objects/abstract.c:2228
#4 0x080bc202 in PyEval_EvalFrame (f=0x844ac1c) at ../Python/ceval.c:2107
#5 0x080bf87d in PyEval_EvalFrame (f=0x822e7dc) at ../Python/ceval.c:3640
#6 0x080c0272 in PyEval_EvalCodeEx (co=0x83ab4e0, globals=0x2,
locals=0x81373e8, args=0x822e928, argcount=6, kws=0x81be290, kwcount=0,
defs=0x82cb9d8, defcount=2, closure=0x0) at ../Python/ceval.c:2736
#7 0x080bdaf8 in PyEval_EvalFrame (f=0x81be104) at ../Python/ceval.c:3650
#8 0x080c0272 in PyEval_EvalCodeEx (co=0x83ab5e0, globals=0x2,
locals=0x81373e8, args=0x0, argcount=7, kws=0x81a2ef0, kwcount=0,
defs=0x83ae878, defcount=6, closure=0x0) at ../Python/ceval.c:2736
#9 0x080bdaf8 in PyEval_EvalFrame (f=0x81a2d74) at ../Python/ceval.c:3650
#10 0x080c0272 in PyEval_EvalCodeEx (co=0x83a87a0, globals=0x2,
locals=0x81373e8, args=0x1, argcount=1, kws=0x0, kwcount=0,
defs=0x83ac628, defcount=3, closure=0x0) at ../Python/ceval.c:2736
#11 0x08108e8e in function_call (func=0x83b3a04, arg=0x81f50ac, kw=0x0)
at ../Objects/funcobject.c:548
#12 0x0806412c in PyObject_Call (func=0x841b000, arg=0x81f50ac, kw=0x0)
at ../Objects/abstract.c:1795
#13 0x080b8427 in PyEval_CallObjectWithKeywords (func=0x83b3a04,
arg=0x81f50ac, kw=0x0) at ../Python/ceval.c:3425
#14 0xd009f393 in array_str (self=0x2) at numpy/core/src/arrayobject.c:4259
#15 0x080850d2 in PyObject_Str (v=0x2) at ../Objects/object.c:347
#16 0x08085212 in internal_print (op=0x82a6708, fp=0x815bf90, flags=1,
nesting=0) at ../Objects/object.c:241
#17 0x0806eafb in PyFile_WriteObject (v=0x82a6708, f=0x82a6708, flags=1)
at ../Objects/fileobject.c:2036
#18 0x080bcc84 in PyEval_EvalFrame (f=0x819ccbc) at ../Python/ceval.c:1538
#19 0x080c0272 in PyEval_EvalCodeEx (co=0x81e70a0, globals=0x2,
locals=0x81373e8, args=0x0, argcount=0, kws=0x0, kwcount=0, defs=0x0,
defcount=0, closure=0x0) at ../Python/ceval.c:2736
#20 0x080c03e6 in PyEval_EvalCode (co=0x81e70a0, globals=0x8175824,
locals=0x8175824) at ../Python/ceval.c:484
#21 0x080e5450 in PyRun_FileExFlags (fp=0x815bfb0,
filename=0x8046927 "/home/titan/johnh/tmp.py", start=257,
globals=0x8175824, locals=0x8175824, closeit=1, flags=0x81e70a0)
at ../Python/pythonrun.c:1265
#22 0x080e5d36 in PyRun_SimpleFileExFlags (fp=0x815bfb0,
filename=0x8046927 "/home/titan/johnh/tmp.py", closeit=1, flags=0x8046628)
at ../Python/pythonrun.c:860
#23 0x0805d41b in Py_Main (argc=1, argv=0x8046740) at ../Modules/main.c:492
#24 0x0805cb0b in main (argc=2, argv=0x8046740) at ../Modules/python.c:23
Sameer
More information about the NumPy-Discussion
mailing list