[vtk-developers] Patch to vtkWrapPython.c to make wrapped Python code GIL-friendly

Charl P. Botha cpbotha at gmail.com
Mon Jul 4 12:03:32 EDT 2005


Hi there Sander,

On 7/1/05, Sander Niemeijer <niemeijer at science-and-technology.nl> wrote:
> The point is, I have already been bitten by the current behaviour of
> vtkPythonCommand::Execute.
> When in our wxPython/VTK application a vtkPytonCommand::Execute is
> called to run a Python method (that was registered as observer on a VTK
> object) we receive a SEGFAULT:
>    PyFrame_New (tstate=0x0, code=0x43997a20, globals=0x4187c3e4,
> locals=0x0)
>         at Objects/frameobject.c:540
>         540             PyFrameObject *back = tstate->frame;
> The tstate (current Python thread state) is NULL, which should never
> happen.
> I was first able to 'fix' this by just building everything (i.e.
> Python, VTK, wxPython) without thread support, but I recently
> discovered the PyGILState API and was able to fix our crash by adding
> PyGILState_Ensure() and PyGILState_Release() calls to the
> vtkPythonCommand:Execute function.

I haven't ever seen this specific behaviour before, but I think I know
why.  Do you perhaps have a small Python test case with which I can
reproduce this segfault on a stock VTK CVS build?

Thanks,
Charl

-- 
charl p. botha http://cpbotha.net/ http://visualisation.tudelft.nl/

c.p.botha ||at|| ewi.tudelft.nl - tu delft work-related email
cpbotha ||at|| cpbotha.net - everything else



More information about the vtk-developers mailing list