[vtkusers] python reader.GetFileName() seg faults

Chris Myers myers at tc.cornell.edu
Thu Jul 27 12:42:49 EDT 2000


Randy,

Re: Python seg faulting with reader.GetFileName()...

>From the trace below, you can see that Python is seg faulting in
PyString_FromString().  Poking around comp.lang.python, I find that,
at least as of a few months ago (i.e., in version 1.5.2),
PyString_FromString applied to a NULL char* pointer will seg fault
rather than return Py_None, i.e., that one must explicitly check that
the pointer is not NULL before calling the string conversion function.

I am running Python 1.5.2; you are running 1.6a2.  Perhaps Python
has changed the behavior of PyString_FromString in 1.6a2, but I haven't
yet found any explicit mention of that in the 1.6 Change Logs.

I am running a reasonably recent nightly release of VTK (a few weeks
old), so I doubt that the Python wrapper generation is significantly
different between your version and mine.  Looking at 
python/vtkUnstructuredGridReaderPython.cxx, I find the following 
fragment:

   if (PyArg_ParseTuple(args, ""))
   {
	if (!error)
        {
             temp20 = op->GetFileName();
             return PyString_FromString(temp20);
        }
   }

If you have that file still lying around, you might want to check
whether the pointer is being checked before the function call,
but I suspect the difference is in the upgrade to Python.

At the very least, the VTK wrapper code generation seems insufficient
for Python 1.5.2.  

Can this be easily fixed in VTK?


Thanks,

Chris

--------------------------------------------------------------------------

Program received signal SIGSEGV, Segmentation fault.
0x8072253 in PyString_FromString ()
(gdb) where
#0  0x8072253 in PyString_FromString ()
#1  0x40c1185b in PyvtkUnstructuredGridReader_GetFileName (self=0x81b5698, 
    args=0x80a10d8) at python/vtkUnstructuredGridReaderPython.cxx:121
#2  0x8053ec0 in PyEval_CallObjectWithKeywords ()
#3  0x8053dd8 in PyEval_CallObjectWithKeywords ()
#4  0x8052fc5 in PyEval_EvalCode ()
#5  0x80512db in PyEval_EvalCode ()
#6  0x805f804 in PyRun_File ()
#7  0x805ee92 in PyRun_InteractiveOne ()
#8  0x805ed47 in PyRun_InteractiveLoop ()
#9  0x805eca7 in PyRun_AnyFile ()
#10 0x804fc02 in Py_Main ()
#11 0x804f746 in main ()
#12 0x400699cb in __libc_start_main (main=0x804f738 <main>, argc=1, 
    argv=0xbffff744, init=0x804ed84 <_init>, fini=0x8084c3c <_fini>, 
    rtld_fini=0x4000ae60 <_dl_fini>, stack_end=0xbffff73c)
    at ../sysdeps/generic/libc-start.c:92



On Mon, 24 Jul 2000, Randy Heiland wrote:

> Date: Mon, 24 Jul 2000 11:19:11 -0500
> From: Randy Heiland <heiland at ncsa.uiuc.edu>
> To: Chris Myers <myers at TC.Cornell.EDU>, vtkusers at public.kitware.com
> Subject: Re: [vtkusers] python reader.GetFileName() seg faults
> 
> Chris,
> 
> fwiw, I don't get this seg fault using:
> 
> v = vtkVersion()
> v.GetVTKSourceVersion()
> vtk version 3.1.2, vtk source $Revision: 1.522 $, $Date: 2000/05/25 20:07:36 $
> (GMT)
> 
> Python 1.6a2 (#1, May 26 2000, 10:07:42) [C] on irix646-64
> 
> 
> Perhaps you could run gdb and find out where it's occurring?
> 
> --Randy
> 
> _______________________________________________
> This is the private VTK discussion list. 
> Please keep messages on-topic. Check the FAQ at: <http://public.kitware.com/cgi-bin/vtkfaq>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/vtkusers
> 






More information about the vtkusers mailing list