[vtkusers] Error handler invoked during threaded algorithm causes SIGSEGV

Peter Wainwright prw at ceiriog.eclipse.co.uk
Sun Aug 31 12:45:52 EDT 2008


Hi,

I have a Python application which handles images. It uses a KWWidgets
application and main window.  By a stupid programming error (ahem...) I
triggered an error during rendering.  This caused the program to crash
out with SIGSEGV.  Examining the core dump (see the attachment) I found
that VTK/KWWidgets was trying to handle the original error when the
segfault occurred.

Thread 1 (the thread in which the segfault occurred) was cloned from
Thread 3 (the main thread).  However, in the cloned thread, winPtr =
Tk_MainWindow(interp) is NULL.

My questions are:

(1) Is it supposed to be legal to do Tk-related stuff in a thread like
this (I know many widgets sets are not thread-safe)

and

(2) If this is not legal, why is VTK trying to invoke the error handler
in the context of the sub-thread?  Should it not somehow pass the error
back to the main thread for processing?

I am working with recent CVS head versions of VTK and KWWidgets on
Ubuntu 8.04

Thank you,

Peter Wainwright

-------------- next part --------------
[Switching to thread 1 (process 7630)]#0  0x00007f6d843c2d6c in Tk_GetImageMasterData (
    interp=0xafd4a0, name=0x148e238 ".0.15.16.image", typePtrPtr=0x42bbc700)
    at /home/prw/src/ubuntu/tk/tk8.4-8.4.16/unix/../generic/tkImage.c:1045
1045	    hPtr = Tcl_FindHashEntry(&winPtr->mainPtr->imageTable, name);
#0  0x00007f6d843c2d6c in Tk_GetImageMasterData (interp=0xafd4a0, name=0x148e238 ".0.15.16.image", 
    typePtrPtr=0x42bbc700) at /home/prw/src/ubuntu/tk/tk8.4-8.4.16/unix/../generic/tkImage.c:1045
#1  0x00007f6d843d219a in Tk_FindPhoto (interp=0xafd4a0, imageName=0x148e238 ".0.15.16.image")
    at /home/prw/src/ubuntu/tk/tk8.4-8.4.16/unix/../generic/tkImgPhoto.c:4303
#2  0x00007f6d8cdb3410 in vtkKWTkUtilities::UpdatePhoto (interp=0xafd4a0, 
    photo_name=0x148e238 ".0.15.16.image", pixels=0x148dde0 "???", width=16, height=16, 
    pixel_size=4, buffer_length=0, update_options=0)
    at /home/prw/src/KWWidgets-Slicer-20080821/vtkKWTkUtilities.cxx:784
#3  0x00007f6d8cdb4101 in vtkKWTkUtilities::UpdatePhoto (app=0xcb46b0, 
    photo_name=0x148e238 ".0.15.16.image", pixels=0x148dde0 "???", width=16, height=16, 
    pixel_size=4, buffer_length=0, update_options=0)
    at /home/prw/src/KWWidgets-Slicer-20080821/vtkKWTkUtilities.cxx:959
#4  0x00007f6d8cdb438f in vtkKWTkUtilities::SetImageOptionToPixels (widget=0xcb5ef0, 
    pixels=0x148dde0 "???", width=16, height=16, pixel_size=4, buffer_length=0, 
    image_option=0x7f6d8cff9eb4 "-image")
    at /home/prw/src/KWWidgets-Slicer-20080821/vtkKWTkUtilities.cxx:1034
#5  0x00007f6d8ccda274 in vtkKWLabel::SetImageToPixels (this=0xcb5ef0, pixels=0x148dde0 "???", 
    width=16, height=16, pixel_size=4, buffer_length=0)
    at /home/prw/src/KWWidgets-Slicer-20080821/vtkKWLabel.cxx:505
#6  0x00007f6d8ccda30f in vtkKWLabel::SetImageToIcon (this=0xcb5ef0, icon=0x148dda0)
    at /home/prw/src/KWWidgets-Slicer-20080821/vtkKWLabel.cxx:489
#7  0x00007f6d8ccda380 in vtkKWLabel::SetImageToPredefinedIcon (this=0xcb5ef0, icon_index=4)
    at /home/prw/src/KWWidgets-Slicer-20080821/vtkKWLabel.cxx:478
#8  0x00007f6d8cdf5825 in vtkKWWindowBase::SetErrorIcon (this=0xcb53f0, s=2)
    at /home/prw/src/KWWidgets-Slicer-20080821/vtkKWWindowBase.cxx:1152
#9  0x00007f6d8d5a515f in vtkKWWindowBase::SetErrorIconToRed (this=0xcb53f0)
    at /home/prw/src/KWWidgets-Slicer-20080821/vtkKWWindowBase.h:97
#10 0x00007f6d8cdf64c7 in vtkKWWindowBase::ProcessCallbackCommandEvents (this=0xcb53f0, 
    caller=0xcb46b0, event=2180, calldata=0x148dc80)
    at /home/prw/src/KWWidgets-Slicer-20080821/vtkKWWindowBase.cxx:1467
#11 0x00007f6d8cd2e529 in vtkKWObject::ProcessCallbackCommandEventsFunction (object=0xcb46b0, 
    event=2180, clientdata=0xcb53f0, calldata=0x148dc80)
    at /home/prw/src/KWWidgets-Slicer-20080821/vtkKWObject.cxx:184
#12 0x00007f6d847c5c28 in vtkCallbackCommand::Execute (this=0xcff4c0, caller=0xcb46b0, event=2180, 
    callData=0x148dc80) at /home/prw/src/VTK-20080821/Common/vtkCallbackCommand.cxx:42
#13 0x00007f6d8487fb18 in vtkSubjectHelper::InvokeEvent (this=0xcb4fe0, event=2180, 
    callData=0x148dc80, self=0xcb46b0) at /home/prw/src/VTK-20080821/Common/vtkObject.cxx:602
#14 0x00007f6d8487fc30 in vtkObject::InvokeEvent (this=0xcb46b0, event=2180, callData=0x148dc80)
    at /home/prw/src/VTK-20080821/Common/vtkObject.cxx:770
#15 0x00007f6d8cc4c8dc in vtkKWApplication::ErrorMessage (this=0xcb46b0, 
    message=0x148dc80 "ERROR: In /home/prw/src/VTK-20080821/Filtering/vtkImageData.cxx, line 1473\nvtkImageData (0x1177620): GetScalarPointer: Pixel (8000, 10840, 0) not in memory.\n Current extent= (8000, 8399, 10400, 10799,"...) at /home/prw/src/KWWidgets-Slicer-20080821/vtkKWApplication.cxx:2642
#16 0x00007f6d8cc5430c in vtkKWOutputWindow::DisplayErrorText (this=0xcb4ae0, 
    t=0x148dc80 "ERROR: In /home/prw/src/VTK-20080821/Filtering/vtkImageData.cxx, line 1473\nvtkImageData (0x1177620): GetScalarPointer: Pixel (8000, 10840, 0) not in memory.\n Current extent= (8000, 8399, 10400, 10799,"...) at /home/prw/src/KWWidgets-Slicer-20080821/vtkKWApplication.cxx:152
#17 0x00007f6d84886150 in vtkOutputWindowDisplayErrorText (
    message=0x148dc80 "ERROR: In /home/prw/src/VTK-20080821/Filtering/vtkImageData.cxx, line 1473\nvtkImageData (0x1177620): GetScalarPointer: Pixel (8000, 10840, 0) not in memory.\n Current extent= (8000, 8399, 10400, 10799,"...) at /home/prw/src/VTK-20080821/Common/vtkOutputWindow.cxx:42
#18 0x00007f6d84e6254a in vtkImageData::GetScalarPointer (this=0x1177620, coordinate=0x42bbcf60)
    at /home/prw/src/VTK-20080821/Filtering/vtkImageData.cxx:1468
#19 0x00007f6d84e5e331 in vtkImageData::GetScalarPointerForExtent (this=0x1177620, 
    extent=0x42bbd030) at /home/prw/src/VTK-20080821/Filtering/vtkImageData.cxx:1438
#20 0x00007f6d85399b56 in vtkImageAppend::ThreadedRequestData (this=0x116d540, 
    inputVector=0x1177110, inData=0x148d630, outData=0x148d530, outExt=0x42bbd0d0, id=1)
    at /home/prw/src/VTK-20080821/Imaging/vtkImageAppend.cxx:400
#21 0x00007f6d84f4a6df in vtkThreadedImageAlgorithmThreadedExecute (arg=0x116b0b8)
    at /home/prw/src/VTK-20080821/Filtering/vtkThreadedImageAlgorithm.cxx:203
#22 0x00007f6d8e6853f7 in start_thread () from /lib/libpthread.so.0
#23 0x00007f6d8dd6cb2d in clone () from /lib/libc.so.6
#24 0x0000000000000000 in ?? ()

[Switching to thread 2 (process 7628)]#0  0x00007f6d8dd65da2 in select () from /lib/libc.so.6
#0  0x00007f6d8dd65da2 in select () from /lib/libc.so.6
#1  0x00007f6d840d3d60 in NotifierThreadProc (clientData=0x0)
    at /home/prw/src/ubuntu/tcl/tcl8.4-8.4.16/unix/tclUnixNotfy.c:988
#2  0x00007f6d8e6853f7 in start_thread () from /lib/libpthread.so.0
#3  0x00007f6d8dd6cb2d in clone () from /lib/libc.so.6
#4  0x0000000000000000 in ?? ()

[Switching to thread 3 (process 7615)]#0  0x00007f6d8dd6caf1 in clone () from /lib/libc.so.6
#0  0x00007f6d8dd6caf1 in clone () from /lib/libc.so.6
#1  0x00007f6d8e685a12 in pthread_create@@GLIBC_2.2.5 () from /lib/libpthread.so.0
#2  0x00007f6d8487c69b in vtkMultiThreader::SingleMethodExecute (this=0x116b070)
    at /home/prw/src/VTK-20080821/Common/vtkMultiThreader.cxx:369
#3  0x00007f6d84f4a3ca in vtkThreadedImageAlgorithm::RequestData (this=0x116d540, 
    request=0x1242a10, inputVector=0x1177110, outputVector=0x1179cd0)
    at /home/prw/src/VTK-20080821/Filtering/vtkThreadedImageAlgorithm.cxx:292
#4  0x00007f6d84e5c938 in vtkImageAlgorithm::ProcessRequest (this=0x116d540, request=0x1242a10, 
    inputVector=0x1177110, outputVector=0x1179cd0)
    at /home/prw/src/VTK-20080821/Filtering/vtkImageAlgorithm.cxx:95
#5  0x00007f6d84e06600 in vtkExecutive::CallAlgorithm (this=0x1179c20, request=0x1242a10, 
    direction=1, inInfo=0x1177110, outInfo=0x1179cd0)
    at /home/prw/src/VTK-20080821/Filtering/vtkExecutive.cxx:748
#6  0x00007f6d84dfc0cd in vtkDemandDrivenPipeline::ExecuteData (this=0x1179c20, request=0x1242a10, 
    inInfo=0x1177110, outInfo=0x1179cd0)
    at /home/prw/src/VTK-20080821/Filtering/vtkDemandDrivenPipeline.cxx:502
#7  0x00007f6d84dff990 in vtkDemandDrivenPipeline::ProcessRequest (this=0x1179c20, 
    request=0x1242a10, inInfoVec=0x1177110, outInfoVec=0x1179cd0)
    at /home/prw/src/VTK-20080821/Filtering/vtkDemandDrivenPipeline.cxx:274
#8  0x00007f6d84f339bb in vtkStreamingDemandDrivenPipeline::ProcessRequest (this=0x1179c20, 
    request=0x1242a10, inInfoVec=0x1177110, outInfoVec=0x1179cd0)
    at /home/prw/src/VTK-20080821/Filtering/vtkStreamingDemandDrivenPipeline.cxx:162
#9  0x00007f6d84e089ce in vtkExecutive::ForwardUpstream (this=0x1130e60, request=0x1242a10)
    at /home/prw/src/VTK-20080821/Filtering/vtkExecutive.cxx:645
#10 0x00007f6d84dff90b in vtkDemandDrivenPipeline::ProcessRequest (this=0x1130e60, 
    request=0x1242a10, inInfoVec=0x1122840, outInfoVec=0x1130f30)
    at /home/prw/src/VTK-20080821/Filtering/vtkDemandDrivenPipeline.cxx:260
#11 0x00007f6d84f339bb in vtkStreamingDemandDrivenPipeline::ProcessRequest (this=0x1130e60, 
    request=0x1242a10, inInfoVec=0x1122840, outInfoVec=0x1130f30)
    at /home/prw/src/VTK-20080821/Filtering/vtkStreamingDemandDrivenPipeline.cxx:162
#12 0x00007f6d84dff565 in vtkDemandDrivenPipeline::UpdateData (this=0x1130e60, outputPort=0)
    at /home/prw/src/VTK-20080821/Filtering/vtkDemandDrivenPipeline.cxx:444
#13 0x00007f6d84dea661 in vtkDataObject::UpdateData (this=0x11c1cc0)
    at /home/prw/src/VTK-20080821/Filtering/vtkDataObject.cxx:1063
#14 0x00007f6d87469bd8 in vtkImageActor::RenderOpaqueGeometry (this=0x11c21d0, viewport=0x11e2510)
    at /home/prw/src/VTK-20080821/Rendering/vtkImageActor.cxx:254
#15 0x00007f6d87500a4c in vtkRenderer::UpdateGeometry (this=0x11e2510)
    at /home/prw/src/VTK-20080821/Rendering/vtkRenderer.cxx:567
#16 0x00007f6d875b099f in vtkOpenGLRenderer::DeviceRender (this=0x11e2510)
    at /home/prw/src/VTK-20080821/Rendering/vtkOpenGLRenderer.cxx:269
#17 0x00007f6d875018c5 in vtkRenderer::Render (this=0x11e2510)
    at /home/prw/src/VTK-20080821/Rendering/vtkRenderer.cxx:296
#18 0x00007f6d874fb86c in vtkRendererCollection::Render (this=0xd9c890)
    at /home/prw/src/VTK-20080821/Rendering/vtkRendererCollection.cxx:52
#19 0x00007f6d8750f18a in vtkRenderWindow::DoStereoRender (this=0xd4bf40)
    at /home/prw/src/VTK-20080821/Rendering/vtkRenderWindow.cxx:708
#20 0x00007f6d8750f755 in vtkRenderWindow::DoFDRender (this=0xd4bf40)
    at /home/prw/src/VTK-20080821/Rendering/vtkRenderWindow.cxx:677
#21 0x00007f6d8750ff06 in vtkRenderWindow::DoAARender (this=0xd4bf40)
    at /home/prw/src/VTK-20080821/Rendering/vtkRenderWindow.cxx:564
#22 0x00007f6d87510721 in vtkRenderWindow::Render (this=0xd4bf40)
    at /home/prw/src/VTK-20080821/Rendering/vtkRenderWindow.cxx:377
#23 0x00007f6d875d4814 in vtkXOpenGLRenderWindow::Render (this=0xd4bf40)
    at /home/prw/src/VTK-20080821/Rendering/vtkXOpenGLRenderWindow.cxx:1798
#24 0x00007f6d8ce659b6 in vtkKWRenderWidget::Render (this=0xd9c480)
    at /home/prw/src/KWWidgets-Slicer-20080821/vtkKWRenderWidget.cxx:1507
#25 0x00007f6d8ce678fb in vtkKWRenderWidget::ExposeCallback (this=0xd9c480)
    at /home/prw/src/KWWidgets-Slicer-20080821/vtkKWRenderWidget.cxx:1346
#26 0x00007f6d8cbd54c3 in vtkKWRenderWidgetCppCommand (op=0xd9c480, interp=0xafd4a0, argc=2, 
    argv=0x7fff96ab4af0) at /home/prw/src/KWWidgets-Slicer-20080821/vtkKWRenderWidgetTcl.cxx:1272
#27 0x00007f6d8cbdcd0c in vtkKWRenderWidgetCommand (cd=0x116fdf0, interp=0xafd4a0, argc=2, 
    argv=0x7fff96ab4af0) at /home/prw/src/KWWidgets-Slicer-20080821/vtkKWRenderWidgetTcl.cxx:31
#28 0x00007f6d84035a5e in TclInvokeStringCommand (clientData=0xfe8240, interp=0xafd4a0, objc=2, 
    objv=0x7fff96ab4f20) at /home/prw/src/ubuntu/tcl/tcl8.4-8.4.16/unix/../generic/tclBasic.c:1887
#29 0x00007f6d84037446 in TclEvalObjvInternal (interp=0xafd4a0, objc=2, objv=0x7fff96ab4f20, 
    command=0x7fff96ab52a0 "vtkTemp20 ExposeCallback", length=24, flags=0)
    at /home/prw/src/ubuntu/tcl/tcl8.4-8.4.16/unix/../generic/tclBasic.c:3219
#30 0x00007f6d84038219 in Tcl_EvalEx (interp=0xafd4a0, 
    script=0x7fff96ab52a0 "vtkTemp20 ExposeCallback", numBytes=24, flags=131072)
    at /home/prw/src/ubuntu/tcl/tcl8.4-8.4.16/unix/../generic/tclBasic.c:4011
#31 0x00007f6d84334199 in Tk_BindEvent (bindingTable=0xb421d0, eventPtr=0x122e990, tkwin=0xfc98f0, 
    numObjects=0, objectPtr=0x7fff96ab53b0)
    at /home/prw/src/ubuntu/tk/tk8.4-8.4.16/unix/../generic/tkBind.c:1809
#32 0x00007f6d8433c310 in TkBindEventProc (winPtr=0xfc98f0, eventPtr=0x122e990)
    at /home/prw/src/ubuntu/tk/tk8.4-8.4.16/unix/../generic/tkCmds.c:286
#33 0x00007f6d84347726 in Tk_HandleEvent (eventPtr=0x122e990)
    at /home/prw/src/ubuntu/tk/tk8.4-8.4.16/unix/../generic/tkEvent.c:1059
#34 0x00007f6d84347d69 in WindowEventProc (evPtr=0x122e980, flags=-3)
    at /home/prw/src/ubuntu/tk/tk8.4-8.4.16/unix/../generic/tkEvent.c:1445
#35 0x00007f6d840a3094 in Tcl_ServiceEvent (flags=-3)
    at /home/prw/src/ubuntu/tcl/tcl8.4-8.4.16/unix/../generic/tclNotify.c:640
#36 0x00007f6d840a33b7 in Tcl_DoOneEvent (flags=-3)
    at /home/prw/src/ubuntu/tcl/tcl8.4-8.4.16/unix/../generic/tclNotify.c:881
#37 0x00007f6d8cc5127a in vtkKWApplication::DoOneTclEvent (this=0xcb46b0)
    at /home/prw/src/KWWidgets-Slicer-20080821/vtkKWApplication.cxx:1199
#38 0x00007f6d8cc51956 in vtkKWApplication::Start (this=0xcb46b0, argc=1, argv=0x1227f20)
    at /home/prw/src/KWWidgets-Slicer-20080821/vtkKWApplication.cxx:1067
#39 0x00007f6d8cc51ad1 in vtkKWApplication::Start (this=0xcb46b0)
    at /home/prw/src/KWWidgets-Slicer-20080821/vtkKWApplication.cxx:990
#40 0x00007f6d8da8b8dd in PyvtkKWApplication_Start (self=0x7f6d8e937390, args=0x7f6d8ea57050)
    at /home/prw/src/KWWidgets-Slicer-20080821/Wrapping/Python/KWWidgetsPythonExtraInit.cxx:440
#41 0x000000000048964b in PyEval_EvalFrameEx (f=0x7d8f90, throwflag=<value optimized out>)
    at ../Python/ceval.c:3573
#42 0x000000000048a406 in PyEval_EvalCodeEx (co=0x7f6d8ea4c468, globals=<value optimized out>, 
    locals=<value optimized out>, args=0x0, argcount=0, kws=0x0, kwcount=0, defs=0x0, defcount=0, 
    closure=0x0) at ../Python/ceval.c:2836
#43 0x000000000048a522 in PyEval_EvalCode (co=0x3d0f00, globals=0x42bbd260, locals=0x42bbd9e0)
    at ../Python/ceval.c:494
#44 0x00000000004abe2e in PyRun_FileExFlags (fp=0x75b010, 
    filename=0x7fff96ab76f1 "MyImageViewer2.py", start=<value optimized out>, globals=0x77e460, 
    locals=0x77e460, closeit=1, flags=0x7fff96ab5c40) at ../Python/pythonrun.c:1273
#45 0x00000000004ac0c9 in PyRun_SimpleFileExFlags (fp=0x75b010, 
    filename=0x7fff96ab76f1 "MyImageViewer2.py", closeit=1, flags=0x7fff96ab5c40)
    at ../Python/pythonrun.c:879
#46 0x00000000004145ad in Py_Main (argc=<value optimized out>, argv=<value optimized out>)
    at ../Modules/main.c:523
#47 0x00007f6d8dcb31c4 in __libc_start_main () from /lib/libc.so.6
#48 0x0000000000413b29 in _start ()

* 3 process 7615  0x00007f6d8dd6caf1 in clone () from /lib/libc.so.6
  2 process 7628  0x00007f6d8dd65da2 in select () from /lib/libc.so.6
  1 process 7630  0x00007f6d843c2d6c in Tk_GetImageMasterData (interp=0xafd4a0, 
    name=0x148e238 ".0.15.16.image", typePtrPtr=0x42bbc700)
    at /home/prw/src/ubuntu/tk/tk8.4-8.4.16/unix/../generic/tkImage.c:1045


More information about the vtkusers mailing list