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&#39;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">&lt;<a href="mailto:dave.demarle@kitware.com" target="_blank">dave.demarle@kitware.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Unfortunately, VTK isn&#39;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&#39;t be in until after 6.0.<br>
<br>
If anyone on the list has had success in writing multithreaded VTK<br>
programs, I&#39;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&amp;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>
&lt;<a href="mailto:Gerald.Lodron@joanneum.at">Gerald.Lodron@joanneum.at</a>&gt; wrote:<br>
&gt; Hi<br>
&gt;<br>
&gt; I programmed an own vtk Filter which internally has multiple threads. In<br>
&gt; each thread I create a vtkImageData object using<br>
&gt;<br>
&gt; vtkSmartPointer&lt;vtkImageData&gt;       oImage = vtkImageData::New();<br>
&gt;<br>
&gt; the problem is that sometimes the New() operator crashes, I debugged it the<br>
&gt; the line 61 of vtkImageData.cxx:<br>
&gt;<br>
&gt; this-&gt;Information-&gt;Set(vtkDataObject::DATA_EXTENT(), this-&gt;Extent, 6);<br>
&gt;<br>
&gt; whereby the exact crash is in vtkInformationIntegerPointerKey.cxx on line<br>
&gt; 58:<br>
&gt;<br>
&gt; if(this-&gt;RequiredLength &gt;= 0 &amp;&amp; length != this-&gt;RequiredLength)<br>
&gt;<br>
&gt; wherehy the “this” pointer is zero. I am not so deep familiar with that, any<br>
&gt; suggestions?<br>
&gt;<br>
&gt; DI Gerald Lodron<br>
&gt;<br>
&gt; Machine Vision Applications<br>
&gt;<br>
&gt; DIGITAL - Institute for Information and Communication Technologies<br>
&gt;<br>
&gt; JOANNEUM RESEARCH Forschungsgesellschaft mbH<br>
&gt; Steyrergasse 17, 8010 Graz, AUSTRIA<br>
&gt;<br>
&gt; 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>
&gt; 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>
&gt; web: <a href="http://www.joanneum.at/digital" target="_blank">http://www.joanneum.at/digital</a><br>
&gt; e-mail: <a href="mailto:gerald.lodron@joanneum.at">gerald.lodron@joanneum.at</a><br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
</div></div>&gt; _______________________________________________<br>
&gt; Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
&gt;<br>
&gt; Visit other Kitware open-source projects at<br>
&gt; <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
&gt;<br>
&gt; Please keep messages on-topic and check the VTK FAQ at:<br>
&gt; <a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
&gt;<br>
&gt; Follow this link to subscribe/unsubscribe:<br>
&gt; <a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
&gt;<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>