[vtkusers] Crash in vtkImageMapToColors when upgrading 6.1->6.2

Cory Quammen cory.quammen at kitware.com
Sun Mar 15 00:40:59 EDT 2015


David and Christian,

I have posted a proposed fix for this at
http://review.source.kitware.com/#/t/5576/

Your reviews and testing are appreciated.

Thanks,
Cory

On Fri, Mar 13, 2015 at 8:37 AM, David Gobbi <david.gobbi at gmail.com> wrote:
> Hi Christian,
>
> I noticed this same issue a few days ago and filed a bug report:
> http://www.vtk.org/Bug/view.php?id=15365
>
> Until this bug is fixed, here is a workaround:
>
>   lut->SetNumberOfTableValues(numberOfTableValues);
>   lut->GetTable()->Resize(numberOfTableValues + 3);
>
> Basically, the crash occurs because Resize() is being called by
> multiple threads inside vtkImageMapToColors, so the workaround
> is to call Resize() beforehand.
>
>  - David
>
>
> On Fri, Mar 13, 2015 at 6:11 AM, Christian Askeland
> <christian.askeland at gmail.com> wrote:
>>
>> Hi all,
>>
>> 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.
>>
>> 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.
>>
>> Here is a distilled version of the problem:
>>
>> typedef vtkSmartPointer<vtkImageData> vtkImageDataPtr;
>> typedef vtkSmartPointer<vtkLookupTable> vtkLookupTablePtr;
>> typedef vtkSmartPointer<vtkImageMapToColors> vtkImageMapToColorsPtr;
>>
>> // create simple image data
>> vtkImageDataPtr image = vtkImageDataPtr::New();
>> image->SetExtent(0, 2, 0, 2, 0, 2); // 3x3x3 image
>> image->AllocateScalars(VTK_UNSIGNED_CHAR, 1);
>>
>> // create simple lut data with a custom table size
>> int numberOfTableValues = 257; // anything above 256 (default) fails
>> vtkLookupTablePtr lut = vtkLookupTablePtr::New();
>> lut->SetNumberOfTableValues(numberOfTableValues);
>> lut->SetTableRange(0, numberOfTableValues - 1);
>> lut->Build();
>>
>> // send through a vtkImageMapToColors
>> vtkImageMapToColorsPtr mapper = vtkImageMapToColorsPtr::New();
>> mapper->SetOutputFormatToRGBA();
>> mapper->SetInputData(image);
>> mapper->SetLookupTable(lut);
>> mapper->Update(); // crashes deep inside
>> vtkLookupTable::MapScalarsThroughTable2
>>
>> The call stack in the crashing thread is
>>
>> abort
>> free
>> vtkDataArrayTemplate<unsigned char>::ResizeAndExtend(long long)
>> vtkDataArrayTemplate<unsigned char>::Resize(long long)
>> void (anonymous namespace)::vtkLookupTableMapData<unsigned char>(...)
>> vtkLookupTable::MapScalarsThroughTable2(void*, unsigned char*, int, int,
>> int, int)
>> vtkImageMapToColors::ThreadedRequestData(...)
>> vtkThreadedImageAlgorithmThreadedExecute(...)
>>
>> Even more digging shows that calling
>> vtkLookupTable::MapScalarsThroughTable explicitly after creating the lut
>> removes the crash:
>>
>> unsigned char input = 0;
>> lut->MapScalarsThroughTable2(&input, &input, VTK_UNSIGNED_CHAR, 1, 1, 1);
>>
>> I have not started digging into the vtk code itself yet.
>>
>> I would appreciate if anyone have an idea of what is wrong here. I can
>> file a bug report if noone have a solution.
>>
>



-- 
Cory Quammen
R&D Engineer
Kitware, Inc.


More information about the vtkusers mailing list