[vtkusers] Problem with threads in VTK

Pierre.Fillard at sophia.inria.fr Pierre.Fillard at sophia.inria.fr
Thu Oct 16 12:51:28 EDT 2008


Hi Wagner,

I did a little test with the code you sent and ended up with the
conclusion that it is vtkINRIA3D's fault.

What happens is that the vtkExtractVOI changes the whole extent of the
image. The vtkViewImage3D class was doing a very bad boundary check
(checking all minimal dimensions, i.e. min_x, min_y and min_z of the
image, with 0 and not the value returned by GetWholeExtent()).
Consequently, it happened that the view was looking for a position outside
the point buffer, which was causing the crash.

You can update your vtkINRIA3D copy and things should go back to order.

Hope this helps,
Pierre Fillard.

> Hi all,
>
> I'm writing viewer using vtkViewImage2D and vtkViewImage3DWithTracer (
> from vtkInria3D, because that a copy was be sent to the vtkInria list
> too ) to render a dataset and a vtkExtractVOI to extract a volume of
> interest interactively. Basically, which I do are select a box in a 2D
> viewer, get the points and extract the required data. The extraction
> works fine if I use only one viewer. If I use more than one viewer, it
> crashes in next interaction after set the vtkExtractVOI output in the
> views. My code uses only VTK ( no other GUI support to prevent threads
> from the GUI toolkit ). I think I need to do some more other thing to
> manage the threads, but I really don't know whats I needs. The
> important pieces of the code are explained above:
>
> ---- simple setup of the views, extractor and VTK rendering stuff, in
> class constructor:
>
>   vtkRenderer* rend1 = vtkRenderer::New();
>   vtkRenderer* rend2 = vtkRenderer::New();
>   vtkRenderer* rend3 = vtkRenderer::New();
>   vtkRenderer* rend4 = vtkRenderer::New();
>
>   m_RenderWindow1 = vtkRenderWindow::New();
>   m_RenderWindow2 = vtkRenderWindow::New();
>   m_RenderWindow3 = vtkRenderWindow::New();
>   m_RenderWindow4 = vtkRenderWindow::New();
>
>   m_RenderWindow1->AddRenderer(rend1);
>   m_RenderWindow2->AddRenderer(rend2);
>   m_RenderWindow3->AddRenderer(rend3);
>   m_RenderWindow4->AddRenderer(rend4);
>
>   m_ViewInteractor1 = vtkRenderWindowInteractor::New();
>   m_ViewInteractor2 = vtkRenderWindowInteractor::New();
>   m_ViewInteractor3 = vtkRenderWindowInteractor::New();
>   m_ViewInteractor4 = vtkRenderWindowInteractor::New();
>
>   m_ViewInteractor1->SetRenderWindow(m_RenderWindow1);
>   m_ViewInteractor2->SetRenderWindow(m_RenderWindow2);
>   m_ViewInteractor3->SetRenderWindow(m_RenderWindow3);
>   m_ViewInteractor4->SetRenderWindow(m_RenderWindow4);
>
>   m_View1 = vtkViewImage2DWithTracer::New();
>   m_View2 = vtkViewImage2DWithTracer::New();
>   m_View3 = vtkViewImage2DWithTracer::New();
>   m_View4 = vtkViewImage3D::New();
>
>   m_View1->SetRenderWindow (m_ViewInteractor1->GetRenderWindow());
>   m_View2->SetRenderWindow (m_ViewInteractor2->GetRenderWindow());
>   m_View3->SetRenderWindow (m_ViewInteractor3->GetRenderWindow());
>   m_View4->SetRenderWindow (m_ViewInteractor4->GetRenderWindow());
>
>   m_View1->SetRenderer (rend1);
>   m_View2->SetRenderer (rend2);
>   m_View3->SetRenderer (rend3);
>   m_View4->SetRenderer (rend4);
>
>   rend1->Delete();
>   rend2->Delete();
>   rend3->Delete();
>   rend4->Delete();
> -----------------------------------------------------------------------------------------------------------------------------
> --- set input
>   m_View1->SetImage(image);
>   m_View2->SetImage(image);
>   m_View3->SetImage(image);
>   m_View4->SetImage(image);
>
> -----------------------------------------------------------------------------------------------------------------------------
>
> --- the extract voi method
>
> 	int minz = GetInput()->GetExtent()[4];
> 	int maxz = GetInput()->GetExtent()[5];
> 	Extractor->SetInput(this->GetInput()); // this method returns the
> current image, working fine
> 	Extractor->SetVOI(BoxExtractor->GetStartPosition()[0],
> BoxExtractor->GetEndPosition()[0],
> BoxExtractor->GetStartPosition()[1],
> BoxExtractor->GetEndPosition()[1], minz, maxz);
> 	Extractor->Update(); // the BoxExtractor are my box with positions.
> Working fine too, since I extract and are Ok in the first view.
> 	this->SetInput(Extractor->GetOutput());
> 	this->Render();
>
> -----------------------------------------------------------------------------------------------------------------------------
> --- the render method:
> 	m_View1->Render();
> 	m_View2->Render();
> 	m_View3->Render();
> //	m_View4->Render(); commented because the crash are occurs here in
> first render
>
> -----------------------------------------------------------------------------------------------------------------------------
>
> The crash will occurs in the next render. I really think that's I'm
> done some wrong thing with threads, and the problem are a
> misunderstand of threads management in VTK. I don't well understood
> why two threads here.
>
> The dump of two threads are above:
>
>
>
> -- this is the thread 1
>
> #0  0x00007fb6869ff27f in __lll_unlock_wake_private () from
> /lib/libpthread.so.0
> #1  0x00007fb6869f95d3 in _L_unlock_4096 () from /lib/libpthread.so.0
> #2  0x00007fb6869f8fa9 in pthread_create@@GLIBC_2.2.5 () from
> /lib/libpthread.so.0
> #3  0x00007fb6895ba40f in vtkMultiThreader::SingleMethodExecute
> (this=0x10d2430) at
> /home/wsales/Sources/VTK/Common/vtkMultiThreader.cxx:368
> #4  0x00007fb689c56532 in vtkThreadedImageAlgorithm::RequestData
> (this=0x10d1740, request=0x20537b0, inputVector=0xf7df10,
> outputVector=0x11f6560) at
> /home/wsales/Sources/VTK/Filtering/vtkThreadedImageAlgorithm.cxx:292
> #5  0x00007fb68a1feaf9 in vtkImageMapToColors::RequestData
> (this=0x10d1740, request=0x20537b0, inputVector=0xf7df10,
> outputVector=0x11f6560) at
> /home/wsales/Sources/VTK/Imaging/vtkImageMapToColors.cxx:100
> #6  0x00007fb689b6a06c in vtkImageAlgorithm::ProcessRequest
> (this=0x10d1740, request=0x20537b0, inputVector=0xf7df10,
> outputVector=0x11f6560) at
> /home/wsales/Sources/VTK/Filtering/vtkImageAlgorithm.cxx:95
> #7  0x00007fb689b1c9a8 in vtkExecutive::CallAlgorithm (this=0x12308d0,
> request=0x20537b0, direction=1, inInfo=0xf7df10, outInfo=0x11f6560) at
> /home/wsales/Sources/VTK/Filtering/vtkExecutive.cxx:748
> #8  0x00007fb689b13471 in vtkDemandDrivenPipeline::ExecuteData
> (this=0x12308d0, request=0x20537b0, inInfo=0xf7df10,
> outInfo=0x11f6560) at
> /home/wsales/Sources/VTK/Filtering/vtkDemandDrivenPipeline.cxx:502
> #9  0x00007fb689b16d34 in vtkDemandDrivenPipeline::ProcessRequest
> (this=0x12308d0, request=0x20537b0, inInfoVec=0xf7df10,
> outInfoVec=0x11f6560) at
> /home/wsales/Sources/VTK/Filtering/vtkDemandDrivenPipeline.cxx:274
> #10 0x00007fb689c40441 in
> vtkStreamingDemandDrivenPipeline::ProcessRequest (this=0x12308d0,
> request=0x20537b0, inInfoVec=0xf7df10, outInfoVec=0x11f6560) at
> /home/wsales/Sources/VTK/Filtering/vtkStreamingDemandDrivenPipeline.cxx:158
> #11 0x00007fb689b16909 in vtkDemandDrivenPipeline::UpdateData
> (this=0x12308d0, outputPort=0) at
> /home/wsales/Sources/VTK/Filtering/vtkDemandDrivenPipeline.cxx:444
> #12 0x00007fb689b01959 in vtkDataObject::UpdateData (this=0xfb3990) at
> /home/wsales/Sources/VTK/Filtering/vtkDataObject.cxx:1072
> #13 0x00007fb68c5ce230 in vtkImageActor::RenderOpaqueGeometry
> (this=0x10d4ac0, viewport=0xf57d60) at
> /home/wsales/Sources/VTK/Rendering/vtkImageActor.cxx:254
> #14 0x00007fb68c66414c in vtkRenderer::UpdateGeometry (this=0xf57d60)
> at /home/wsales/Sources/VTK/Rendering/vtkRenderer.cxx:567
> #15 0x00007fb68c7118eb in vtkOpenGLRenderer::DeviceRender
> (this=0xf57d60) at
> /home/wsales/Sources/VTK/Rendering/vtkOpenGLRenderer.cxx:269
> #16 0x00007fb68c664fc5 in vtkRenderer::Render (this=0xf57d60) at
> /home/wsales/Sources/VTK/Rendering/vtkRenderer.cxx:296
> #17 0x00007fb68c65ef6c in vtkRendererCollection::Render
> (this=0xf59010) at
> /home/wsales/Sources/VTK/Rendering/vtkRendererCollection.cxx:52
> #18 0x00007fb68c67282e in vtkRenderWindow::DoStereoRender
> (this=0xf58db0) at
> /home/wsales/Sources/VTK/Rendering/vtkRenderWindow.cxx:708
> #19 0x00007fb68c672df9 in vtkRenderWindow::DoFDRender (this=0xf58db0)
> at /home/wsales/Sources/VTK/Rendering/vtkRenderWindow.cxx:677
> #20 0x00007fb68c6735aa in vtkRenderWindow::DoAARender (this=0xf58db0)
> at /home/wsales/Sources/VTK/Rendering/vtkRenderWindow.cxx:564
> #21 0x00007fb68c673dc5 in vtkRenderWindow::Render (this=0xf58db0) at
> /home/wsales/Sources/VTK/Rendering/vtkRenderWindow.cxx:377
> #22 0x00007fb68c735254 in vtkXOpenGLRenderWindow::Render
> (this=0xf58db0) at
> /home/wsales/Sources/VTK/Rendering/vtkXOpenGLRenderWindow.cxx:1798
> #23 0x00007fb6887c0697 in vtkSynchronizedView::Render (this=0x105b3a0)
> at
> /home/wsales/Sources/vtkinria3d/vtkRenderingAddOn/vtkSynchronizedView.cxx:642
> #24 0x00007fb6887c7111 in vtkViewImage::SyncSetCurrentPoint
> (this=0xfc2130, p_point=0x7fff9889b350) at
> /home/wsales/Sources/vtkinria3d/vtkRenderingAddOn/vtkViewImage.cxx:458
> #25 0x00007fb6887c70cb in vtkViewImage::SyncSetCurrentPoint
> (this=0x1014a20, p_point=0x7fff9889b350) at
> /home/wsales/Sources/vtkinria3d/vtkRenderingAddOn/vtkViewImage.cxx:455
> #26 0x00007fb6887c70cb in vtkViewImage::SyncSetCurrentPoint
> (this=0xfd5490, p_point=0x7fff9889b350) at
> /home/wsales/Sources/vtkinria3d/vtkRenderingAddOn/vtkViewImage.cxx:455
> #27 0x00007fb6887bc0d3 in vtkViewImage::SyncSetPosition
> (this=0xfd5490, p_point=0x7fff9889b350) at
> /home/wsales/Sources/vtkinria3d/vtkRenderingAddOn/vtkViewImage.h:307
> #28 0x00007fb6887bb39a in vtkViewImage2DCommand::ChangeZSlice
> (this=0x1042ad0, p_isi=0x103b960) at
> /home/wsales/Sources/vtkinria3d/vtkRenderingAddOn/vtkViewImage2DCommand.cxx:314
> #29 0x00007fb6887bbda4 in vtkViewImage2DCommand::Execute
> (this=0x1042ad0, caller=0x103b960, event=1001, callData=0x103b960) at
> /home/wsales/Sources/vtkinria3d/vtkRenderingAddOn/vtkViewImage2DCommand.cxx:125
> #30 0x00007fb6895bd88c in vtkSubjectHelper::InvokeEvent
> (this=0x1041fe0, event=1001, callData=0x103b960, self=0x103b960) at
> /home/wsales/Sources/VTK/Common/vtkObject.cxx:602
> #31 0x00007fb6895bd9a4 in vtkObject::InvokeEvent (this=0x103b960,
> event=1001, callData=0x103b960) at
> /home/wsales/Sources/VTK/Common/vtkObject.cxx:770
> #32 0x00007fb6887aadf4 in
> vtkInteractorStyleImage2D::ZSliceWheelBackward (this=0x103b960) at
> /home/wsales/Sources/vtkinria3d/vtkRenderingAddOn/vtkInteractorStyleImage2D.cxx:596
> #33 0x00007fb6887aa687 in
> vtkInteractorStyleImage2D::OnMouseWheelBackward (this=0x103b960) at
> /home/wsales/Sources/vtkinria3d/vtkRenderingAddOn/vtkInteractorStyleImage2D.cxx:764
> #34 0x00007fb68c5df348 in vtkInteractorStyle::ProcessEvents (event=28,
> clientdata=0x103b960, calldata=0x0) at
> /home/wsales/Sources/VTK/Rendering/vtkInteractorStyle.cxx:1020
> #35 0x00007fb689508c14 in vtkCallbackCommand::Execute (this=0x103baa0,
> caller=0xf77bd0, event=28, callData=0x0) at
> /home/wsales/Sources/VTK/Common/vtkCallbackCommand.cxx:42
> #36 0x00007fb6895bd88c in vtkSubjectHelper::InvokeEvent
> (this=0xf8fcc0, event=28, callData=0x0, self=0xf77bd0) at
> /home/wsales/Sources/VTK/Common/vtkObject.cxx:602
> #37 0x00007fb6895bd9a4 in vtkObject::InvokeEvent (this=0xf77bd0,
> event=28, callData=0x0) at
> /home/wsales/Sources/VTK/Common/vtkObject.cxx:770
> #38 0x00007fb68c6db2f0 in vtkXRenderWindowInteractorCallback
> (client_data=0xf77bd0, event=0x7fff9889c050) at
> /home/wsales/Sources/VTK/Rendering/vtkXRenderWindowInteractor.cxx:697
> #39 0x00007fb68c204345 in XtDispatchEventToWidget () from
> /usr/lib/libXt.so.6
> #40 0x00007fb68c204c70 in ?? () from /usr/lib/libXt.so.6
> #41 0x00007fb68c203d1b in XtDispatchEvent () from /usr/lib/libXt.so.6
> #42 0x00007fb68c6dcf12 in vtkXRenderWindowInteractor::Start
> (this=0xf591c0) at
> /home/wsales/Sources/VTK/Rendering/vtkXRenderWindowInteractor.cxx:276
> #43 0x000000000076528e in AbstractVTKPageView::Enable (this=0xf564a0)
> at /home/wsales/Sources/MarkII/src/AbstractVTKPageView.cpp:433
> #44 0x000000000053372d in main (argc=1, argv=0x7fff9889c308) at
> /home/wsales/Sources/MarkII/src/main.cpp:111
>
> --- the is the thread two
> #0  0x00007fb6895a3f2b in vtkLookupTableMapData<short> (self=0xfa18d0,
> input=0x0, output=0x20749a0 "", length=1, inIncr=1, outFormat=4) at
> /home/wsales/Sources/VTK/Common/vtkLookupTable.cxx:562
> #1  0x00007fb689597cc4 in vtkLookupTable::MapScalarsThroughTable2
> (this=0xfa18d0, input=0x0, output=0x20749a0 "", inputDataType=4,
> numberOfValues=1, inputIncrement=1, outputFormat=4) at
> /home/wsales/Sources/VTK/Common/vtkLookupTable.cxx:814
> #2  0x00007fb68a1fe0fa in vtkImageMapToColorsExecute (self=0x10d1740,
> inData=0x1ccf040, inPtr=0x0, outData=0xfb3990, outPtr=0x20749a0 "",
> outExt=0x426a3fc0, id=1) at
> /home/wsales/Sources/VTK/Imaging/vtkImageMapToColors.cxx:225
> #3  0x00007fb68a1fe352 in vtkImageMapToColors::ThreadedRequestData
> (this=0x10d1740, inData=0x2053ba0, outData=0x2053be0,
> outExt=0x426a3fc0, id=1) at
> /home/wsales/Sources/VTK/Imaging/vtkImageMapToColors.cxx:266
> #4  0x00007fb689c56847 in vtkThreadedImageAlgorithmThreadedExecute
> (arg=0x10d2478) at
> /home/wsales/Sources/VTK/Filtering/vtkThreadedImageAlgorithm.cxx:203
> #5  0x00007fb6869f83f7 in start_thread () from /lib/libpthread.so.0
> #6  0x00007fb6801c2b2d in clone () from /lib/libc.so.6
> #7  0x0000000000000000 in ?? ()
>
>
> Can someone helps?
>
> Regards,
>
> Wagner Sales
>


-- 





More information about the vtkusers mailing list