<div dir="ltr">Cornelius,<div><br></div><div>Thank you for the detailed bug report and your findings! <a href="mailto:vtk-developers@vtk.org">vtk-developers@vtk.org</a> (CC'ed) is a more appropriate list for this problem as it is VTK code in question, but no worries. I have filed an issue with your message in the VTK bug tracker for further tracking of this issue:</div><div><br></div><div><a href="https://gitlab.kitware.com/vtk/vtk/issues/17153">https://gitlab.kitware.com/vtk/vtk/issues/17153</a><br></div><div><br></div><div>Thanks!</div><div><br></div><div>Cory</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Oct 22, 2017 at 9:25 AM, Cornelis Bockemühl <span dir="ltr"><<a href="mailto:cornelis.bockemuehl@gmail.com" target="_blank">cornelis.bockemuehl@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Dear VTK developers,<div><br></div><div>First of all: Am I posting this maybe in the wrong mailing list??</div><div><br></div><div>Anyway, here I go: In some project I am using the vtkIntersectPolyData filter. This works as expected many times, but from time to time I had crashes. I managed to track down these crashes to a little bug in that class that can be fixed by a very little change:</div><div><br></div><div>in vtkIntersectionPolyDataFilter.<wbr>cxx(14'1), replace</div><div><br></div><div><pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(9,46,100)"> lineBool</span><span style="color:rgb(192,192,192)"> </span>=<span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,128,0)">new</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,128,0)">bool</span>[<span style="color:rgb(9,46,100)">pd</span>-><span style="font-style:italic;color:rgb(0,103,124)">GetNumberOfCells</span>()];</pre></div><div><br></div><div>by</div><div><pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(9,46,100)"><br></span></pre><pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(9,46,100)"> lineBool</span><span style="color:rgb(192,192,192)"> </span>=<span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,128,0)">new</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,128,0)">bool</span>[<span style="color:rgb(9,46,100)">pd</span>-><span style="font-style:italic;color:rgb(0,103,124)">GetNumberOfCells</span>()<span style="color:rgb(192,192,192)"> </span>+<span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">1</span>];</pre></div><div><br></div><div>The crash happened when this array was released (heap corruption), and it turned out that indeed under some circumstances the program writes one element more than there is allocated memory. This happens if further down in the GetSingleLoop function the "else if" branch is chosen inside the "if -- else if -- else" construct: Here the pd cells array is extended by one element.</div><div><br></div><div>With the above fix the crash goes indeed away, but then later on the program throws an exception at vtkCellLinks.h(171):</div><div><br></div><div><pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">/**</span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">*</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">Increment</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">the</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">count</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">of</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">the</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">number</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">of</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">cells</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">using</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">the</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">point.</span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">*/</span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,128,0)">void</span><span style="color:rgb(192,192,192)"> </span><span style="font-weight:600;color:rgb(0,103,124)">IncrementLinkCount</span>(<span style="color:rgb(128,0,128)">vtkIdType</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(9,46,100)">ptId</span>)<span style="color:rgb(192,192,192)"> </span>{<span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,128,0)">this</span>-><span style="color:rgb(128,0,0)">Array</span>[<span style="color:rgb(9,46,100)">ptId</span>].<span style="color:rgb(128,0,0)">ncells</span>++;};</pre>
<pre style="margin-top:0px;margin-bottom:0px"><br></pre><pre style="margin-top:0px;margin-bottom:0px">call stack at this point:</pre><pre style="margin-top:0px;margin-bottom:0px"><br></pre><pre style="margin-top:0px;margin-bottom:0px">1 vtkCellLinks::<wbr>IncrementLinkCount vtkCellLinks.h 171 0x7feced1c91a
2 vtkCellLinks::BuildLinks vtkCellLinks.cxx 153 0x7feced1a89a
3 vtkPolyData::BuildLinks vtkPolyData.cxx 1096 0x7fecf022ff1
4 debug_<wbr>vtkIntersectionPolyDataFilter:<wbr>:Impl::SplitCell debug_<wbr>vtkIntersectionPolyDataFilter.<wbr>cxx 1007 0x7fec0c994e2
5 debug_<wbr>vtkIntersectionPolyDataFilter:<wbr>:Impl::SplitMesh debug_<wbr>vtkIntersectionPolyDataFilter.<wbr>cxx 630 0x7fec0c971cc
6 debug_<wbr>vtkIntersectionPolyDataFilter:<wbr>:RequestData debug_<wbr>vtkIntersectionPolyDataFilter.<wbr>cxx 2590 0x7fec0c94531
7 vtkPolyDataAlgorithm::<wbr>ProcessRequest vtkPolyDataAlgorithm.cxx 90 0x7fecf556116
8 vtkExecutive::CallAlgorithm vtkExecutive.cxx 775 0x7fecf50eb55
9 vtkDemandDrivenPipeline::<wbr>ExecuteData vtkDemandDrivenPipeline.cxx 491 0x7fecf50477c
10 vtkCompositeDataPipeline::<wbr>ExecuteData vtkCompositeDataPipeline.cxx 179 0x7fecf4fc560
11 vtkDemandDrivenPipeline::<wbr>ProcessRequest vtkDemandDrivenPipeline.cxx 274 0x7fecf503343
12 vtkStreamingDemandDrivenPipeli<wbr>ne::ProcessRequest vtkStreamingDemandDrivenPipeli<wbr>ne.cxx 328 0x7fecf588f67
13 vtkDemandDrivenPipeline::<wbr>UpdateData vtkDemandDrivenPipeline.cxx 444 0x7fecf5042da
14 vtkStreamingDemandDrivenPipeli<wbr>ne::Update vtkStreamingDemandDrivenPipeli<wbr>ne.cxx 403 0x7fecf589412
15 vtkStreamingDemandDrivenPipeli<wbr>ne::Update vtkStreamingDemandDrivenPipeli<wbr>ne.cxx 366 0x7fecf58916c
16 vtkAlgorithm::Update vtkAlgorithm.cxx 1457 0x7fecf4e5348
17 vtkAlgorithm::Update vtkAlgorithm.cxx 1451 0x7fecf4e53b3
18 vtkCemTestIntersectionFilter::<wbr>RequestData vtkCemTestIntersectionFilter.<wbr>cxx 252 0x7fec0c84e7f
19 vtkPolyDataAlgorithm::<wbr>ProcessRequest vtkPolyDataAlgorithm.cxx 90 0x7fecf556116
20 vtkExecutive::CallAlgorithm vtkExecutive.cxx 775 0x7fecf50eb55
... <More>
</pre></div><div><br></div><div>Note that debug_<wbr>vtkIntersectionPolyDataFilter is a copy of vtkIntersectionPolyDataFilter that I prepared to do my testing and add some debug output stuff etc. without interfering with the original code.</div><div><br></div><div>I guess that the exception is again a consequence of adding that "cell" in GetSingleLoop, but now I must admit that my understanding of the internals of these geometric object classes is not yet good enough to see what went wrong! The code that needs checking by an expert seems to me the following</div><div><br></div><div>vtkIntersectionPolyDataFilter.<wbr>cxx(1536..1555):</div><div><br></div><div><pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">//There</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">is</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">one</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">line</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">attached</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">to</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">point.</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">This</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">means</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">the</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">intersection</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">has</span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">//an</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">open</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">intersection</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">loop</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">(i.e.</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">the</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">surfaces</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">are</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">open</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">and</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">one</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">does</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">not</span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">//completeley</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">intersect</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">the</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">other.</span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">//Make</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">an</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">artificial</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">triangle</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">loop</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">in</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">this</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">case</span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,128,0)">else</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,128,0)">if</span><span style="color:rgb(192,192,192)"> </span>(<span style="color:rgb(9,46,100)">pointCells</span>-><span style="color:rgb(0,103,124)">GetNumberOfIds</span>()<span style="color:rgb(192,192,192)"> </span><<span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">2</span>)</pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span>{</pre>
<pre style="margin-top:0px;margin-bottom:0px"> <span style="font-family:arial,sans-serif;color:rgb(128,0,128)">vtkSmartPointer</span><span style="font-family:arial,sans-serif"><</span><span style="font-family:arial,sans-serif;color:rgb(128,0,128)">vtkPolyData</span><span style="font-family:arial,sans-serif">></span><span style="font-family:arial,sans-serif;color:rgb(192,192,192)"> </span><span style="font-family:arial,sans-serif;color:rgb(9,46,100)">currentpd</span><span style="font-family:arial,sans-serif;color:rgb(192,192,192)"> </span><span style="font-family:arial,sans-serif">=</span><br></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,0,128)">vtkSmartPointer</span><<span style="color:rgb(128,0,128)">vtkPolyData</span>>::<span style="color:rgb(0,103,124)"><wbr>New</span>();</pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,0,128)">vtkSmartPointer</span><<span style="color:rgb(128,0,128)">vtkCellArray</span>><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(9,46,100)">currentcells</span><span style="color:rgb(192,192,192)"> </span>=</pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,0,128)">vtkSmartPointer</span><<span style="color:rgb(128,0,128)">vtkCellArray</span>>:<wbr>:<span style="color:rgb(0,103,124)">New</span>();</pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(9,46,100)">currentcells</span><span style="color:rgb(192,192,192)"> </span>=<span style="color:rgb(192,192,192)"> </span><span style="color:rgb(9,46,100)">pd</span>-><span style="color:rgb(0,103,124)">GetLines</span>();</pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(9,46,100)">currentcells</span>-><span style="color:rgb(0,103,124)">InsertNextCell</span>(<span style="color:rgb(0,0,128)">2</span><wbr>);</pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(9,46,100)">currentcells</span>-><span style="color:rgb(0,103,124)">InsertCellPoint</span>(<span style="color:rgb(9,46,100)"><wbr>nextPt</span>);</pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(9,46,100)">currentcells</span>-><span style="color:rgb(0,103,124)">InsertCellPoint</span>(<span style="color:rgb(9,46,100)"><wbr>startPt</span>);</pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(9,46,100)">nextCell</span><span style="color:rgb(192,192,192)"> </span>=<span style="color:rgb(192,192,192)"> </span><span style="color:rgb(9,46,100)">currentcells</span>-><span style="font-style:italic;color:rgb(0,103,124)">GetNumberOfCells</span><wbr>()-<span style="color:rgb(0,0,128)">1</span>;</pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(9,46,100)">currentpd</span>-><span style="color:rgb(0,103,124)">SetLines</span>(<span style="color:rgb(9,46,100)">currentcel<wbr>ls</span>);</pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(9,46,100)">currentpd</span>-><span style="font-style:italic;color:rgb(0,103,124)">SetPoints</span>(<span style="color:rgb(9,46,100)">pd</span>-><span style="font-style:italic;color:rgb(0,103,124)">GetPo<wbr>ints</span>());</pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(9,46,100)">pd</span>-><span style="font-style:italic;color:rgb(0,103,124)">DeepCopy</span>(<span style="color:rgb(9,46,100)">currentpd</span>);</pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(9,46,100)">pd</span>-><span style="color:rgb(0,103,124)">BuildLinks</span>();</pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span>}</pre>
<pre style="margin-top:0px;margin-bottom:0px"><br></pre></div><div>My guess is that this code is not yet good enough to properly insert the "cell" into pd...</div><div><br></div><div>Any idea?</div><div><br></div><div>Regards,</div><div>Cornelis</div><span class="HOEnZb"><font color="#888888"><div><div><br></div>-- <br><div class="m_-4996734613498183939gmail_signature">Cornelis Bockemühl<br>Basel, Schweiz<br></div>
</div></font></span></div>
<br>______________________________<wbr>_________________<br>
Powered by <a href="http://www.kitware.com" rel="noreferrer" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" target="_blank">http://www.kitware.com/<wbr>opensource/opensource.html</a><br>
<br>
Search the list archives at: <a href="http://markmail.org/search/?q=Paraview-developers" rel="noreferrer" target="_blank">http://markmail.org/search/?q=<wbr>Paraview-developers</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://public.kitware.com/mailman/listinfo/paraview-developers" rel="noreferrer" target="_blank">http://public.kitware.com/<wbr>mailman/listinfo/paraview-<wbr>developers</a><br>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature">Cory Quammen<br>Staff R&D Engineer<br>Kitware, Inc.</div>
</div>