Crash in vtkLookupTableMapData if called from multiple threads
This issue was created automatically from an original Mantis Issue. Further discussion may take place here.
This morning I saw a crash in the following recently-added vtkLookupTable code, when using the lookup table via vtkImageMapToColors on a multi-CPU workstation. By adding print statements, I saw that vtkLookupTableMapData() was being called from multiple threads, which were simultaneously calling the Resize() function. It looks like a mutex will be needed in order to make the code thread-safe.
// Resize the internal table to hold the special colors at the // end. When this function is called repeatedly with the same size // lookup table, memory reallocation will be done only one the first // call if at all. vtkUnsignedCharArray* lookupTable = self->GetTable(); vtkIdType numberOfColors = lookupTable->GetNumberOfTuples(); vtkIdType neededSize = (numberOfColors + vtkLookupTable::NUMBER_OF_SPECIAL_COLORS) * lookupTable->GetNumberOfComponents(); if (lookupTable->GetSize() < neededSize) { lookupTable->Resize(numberOfColors + vtkLookupTable::NUMBER_OF_SPECIAL_COLORS); }