<div dir="ltr">Hi Christian,<div><br></div><div>I noticed this same issue a few days ago and filed a bug report:</div><div><a href="http://www.vtk.org/Bug/view.php?id=15365" target="_blank">http://www.vtk.org/Bug/view.php?id=15365</a><br></div><div><br></div><div>Until this bug is fixed, here is a workaround:</div><div><br></div><div>  lut->SetNumberOfTableValues(numberOfTableValues);</div><div>  lut->GetTable()->Resize(numberOfTableValues + 3);</div><div><br></div><div>Basically, the crash occurs because Resize() is being called by</div><div>multiple threads inside vtkImageMapToColors, so the workaround</div><div>is to call Resize() beforehand.</div><div><br></div><div> - David</div><div><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Mar 13, 2015 at 6:11 AM, Christian Askeland <span dir="ltr"><<a href="mailto:christian.askeland@gmail.com" target="_blank">christian.askeland@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"><div>Hi all,</div><div><br></div><div>I recently upgraded from vtk 6.1.0 to 6.2.0. Most of my rather large vtk-based application runs as before, but I get a crash in vtkImageMapToColors. I am testing on OSX10.8, but my jenkins indicates that this also happens on Ubuntu 14.04.</div><div><br></div><div>The vtkLookupTable that is input to the mapper has a custom NumberOfTableValues, and a little digging has shown that setting this value > 256 (the default) causes the crash.</div><div><br></div><div>Here is a distilled version of the problem:</div><div><br></div><div><span style="white-space:pre-wrap">    </span>typedef vtkSmartPointer<vtkImageData> vtkImageDataPtr;</div><div><span style="white-space:pre-wrap">     </span>typedef vtkSmartPointer<vtkLookupTable> vtkLookupTablePtr;</div><div><span style="white-space:pre-wrap"> </span>typedef vtkSmartPointer<vtkImageMapToColors> vtkImageMapToColorsPtr;</div><div><br></div><div><span style="white-space:pre-wrap">      </span>// create simple image data</div><div><span style="white-space:pre-wrap">      </span>vtkImageDataPtr image = vtkImageDataPtr::New();</div><div><span style="white-space:pre-wrap">  </span>image->SetExtent(0, 2, 0, 2, 0, 2); // 3x3x3 image</div><div><span style="white-space:pre-wrap">    </span>image->AllocateScalars(VTK_UNSIGNED_CHAR, 1);</div><div><br></div><div><span style="white-space:pre-wrap">        </span>// create simple lut data with a custom table size</div><div><span style="white-space:pre-wrap">       </span>int numberOfTableValues = 257; // anything above 256 (default) fails</div><div><span style="white-space:pre-wrap">     </span>vtkLookupTablePtr lut = vtkLookupTablePtr::New();</div><div><span style="white-space:pre-wrap">        </span>lut->SetNumberOfTableValues(numberOfTableValues);</div><div><span style="white-space:pre-wrap">     </span>lut->SetTableRange(0, numberOfTableValues - 1);</div><div><span style="white-space:pre-wrap">       </span>lut->Build();</div><div><br></div><div><span style="white-space:pre-wrap">        </span>// send through a vtkImageMapToColors</div><div><span style="white-space:pre-wrap">    </span>vtkImageMapToColorsPtr mapper = vtkImageMapToColorsPtr::New();</div><div><span style="white-space:pre-wrap">   </span>mapper->SetOutputFormatToRGBA();</div><div><span style="white-space:pre-wrap">      </span>mapper->SetInputData(image);</div><div><span style="white-space:pre-wrap">  </span>mapper->SetLookupTable(lut);</div><div><span style="white-space:pre-wrap">  </span>mapper->Update(); // crashes deep inside vtkLookupTable::MapScalarsThroughTable2 </div><div><br></div><div>The call stack in the crashing thread is </div><div><br></div><div><span style="white-space:pre-wrap">   </span>abort</div><div><span style="white-space:pre-wrap">    </span>free </div><div><span style="white-space:pre-wrap">    </span>vtkDataArrayTemplate<unsigned char>::ResizeAndExtend(long long) </div><div><span style="white-space:pre-wrap">   </span>vtkDataArrayTemplate<unsigned char>::Resize(long long) </div><div><span style="white-space:pre-wrap">    </span>void (anonymous namespace)::vtkLookupTableMapData<unsigned char>(...)</div><div><span style="white-space:pre-wrap">      </span>vtkLookupTable::MapScalarsThroughTable2(void*, unsigned char*, int, int, int, int)</div><div><span style="white-space:pre-wrap">       </span>vtkImageMapToColors::ThreadedRequestData(...)</div><div><span style="white-space:pre-wrap">    </span>vtkThreadedImageAlgorithmThreadedExecute(...)</div><div><br></div><div>Even more digging shows that calling vtkLookupTable::MapScalarsThroughTable explicitly after creating the lut removes the crash:</div><div><br></div><div><span style="white-space:pre-wrap">   </span>unsigned char input = 0;</div><div><span style="white-space:pre-wrap"> </span>lut->MapScalarsThroughTable2(&input, &input, VTK_UNSIGNED_CHAR, 1, 1, 1);</div><div><br></div><div>I have not started digging into the vtk code itself yet. </div><div><br></div><div>I would appreciate if anyone have an idea of what is wrong here. I can file a bug report if noone have a solution.</div><div><br></div></div></blockquote></div></div></div>