Currently there are a lot of pitfalls in using VTK objects in a multi-threaded application. I am working on addressing some of them and I will also create a document describing what is and what is not possible.<div><br></div>
<div>What Gerald is describing should be possible. In fact, I have done it many times in the past. I can't answer why the crash is happening without doing some experimentation. Gerald: does the crash within a minimal code that simply create vtkImageData in multiple threads? Or does it need the full-blown filter to happen?</div>
<div><br></div><div>-berk<br><br><div class="gmail_quote">On Wed, Aug 29, 2012 at 12:14 PM, David E DeMarle <span dir="ltr"><<a href="mailto:dave.demarle@kitware.com" target="_blank">dave.demarle@kitware.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Unfortunately, VTK isn't thread safe, with the exception being<br>
operations (mostly limited to array access methods that are declared<br>
to be thread safe in doxygen) that take place in the Threaded* methods<br>
in subclasses of vtkThreadedImageAlgorithm.<br>
<br>
Berk is working on more wide scale thread/SMP parallel support, but<br>
that won't be in until after 6.0.<br>
<br>
If anyone on the list has had success in writing multithreaded VTK<br>
programs, I'ld like to see examples along with descriptions of what<br>
your approach was and what you had to mutex protect.<br>
<br>
David E DeMarle<br>
Kitware, Inc.<br>
R&D Engineer<br>
21 Corporate Drive<br>
Clifton Park, NY 12065-8662<br>
Phone: <a href="tel:518-881-4909" value="+15188814909">518-881-4909</a><br>
<div><div class="h5"><br>
<br>
On Wed, Aug 29, 2012 at 2:47 AM, Lodron, Gerald<br>
<<a href="mailto:Gerald.Lodron@joanneum.at">Gerald.Lodron@joanneum.at</a>> wrote:<br>
> Hi<br>
><br>
> I programmed an own vtk Filter which internally has multiple threads. In<br>
> each thread I create a vtkImageData object using<br>
><br>
> vtkSmartPointer<vtkImageData> oImage = vtkImageData::New();<br>
><br>
> the problem is that sometimes the New() operator crashes, I debugged it the<br>
> the line 61 of vtkImageData.cxx:<br>
><br>
> this->Information->Set(vtkDataObject::DATA_EXTENT(), this->Extent, 6);<br>
><br>
> whereby the exact crash is in vtkInformationIntegerPointerKey.cxx on line<br>
> 58:<br>
><br>
> if(this->RequiredLength >= 0 && length != this->RequiredLength)<br>
><br>
> wherehy the “this” pointer is zero. I am not so deep familiar with that, any<br>
> suggestions?<br>
><br>
> DI Gerald Lodron<br>
><br>
> Machine Vision Applications<br>
><br>
> DIGITAL - Institute for Information and Communication Technologies<br>
><br>
> JOANNEUM RESEARCH Forschungsgesellschaft mbH<br>
> Steyrergasse 17, 8010 Graz, AUSTRIA<br>
><br>
> phone: <a href="tel:%2B43-316-876-1751" value="+433168761751">+43-316-876-1751</a> personal fax: <a href="tel:%2B43-316-876-91751" value="+4331687691751">+43-316-876-91751</a><br>
> mobile: <a href="tel:%2B43-699-1876-1751" value="+4369918761751">+43-699-1876-1751</a> general fax: <a href="tel:%2B43-316-876-1720" value="+433168761720">+43-316-876-1720</a><br>
> web: <a href="http://www.joanneum.at/digital" target="_blank">http://www.joanneum.at/digital</a><br>
> e-mail: <a href="mailto:gerald.lodron@joanneum.at">gerald.lodron@joanneum.at</a><br>
><br>
><br>
><br>
><br>
</div></div>> _______________________________________________<br>
> Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
><br>
> Visit other Kitware open-source projects at<br>
> <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
><br>
> Please keep messages on-topic and check the VTK FAQ at:<br>
> <a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
><br>
> Follow this link to subscribe/unsubscribe:<br>
> <a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
><br>
_______________________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
</blockquote></div><br></div>