MantisBT - VTK
View Issue Details
0013384VTK(No Category)public2012-08-22 04:522016-08-12 09:55
John Stark 
Bill Lorensen 
normalminorhave not tried
closedmoved 
5.8.0 
 
TBD
crash
0013384: vtkColorTransferFunction::GetTable race condition
When vtkColorTransferFunction is used with vtkImageMapToColors a race condition can arise during running leading to corrupted output or a crash.

The issue is caused by the re-allocation and re-computation of the lookup table (LUT) performed in vtkColorTransferFunction::GetTable(). Because vtkImageMapToColors is a multi-threaded algorithm, GetTable can be called by many threads simultaneously. The re-allocation and computation should be protected with a mutex or critical section.

Only vtkImageData using unsigned char or unsigned short pixel data are affected.

My solution was to protect GetTable with a vtkCriticalSection.
hackaton
patch ColorTransferFn.patch (2,732) 2012-08-23 03:58
https://www.vtk.org/Bug/file/9261/ColorTransferFn.patch
cxx ImageMapToColorsBugTest.cxx (2,558) 2012-08-23 03:58
https://www.vtk.org/Bug/file/9262/ImageMapToColorsBugTest.cxx
cxx TestColorTransferFunction.cxx (3,458) 2013-04-16 16:43
https://www.vtk.org/Bug/file/9433/TestColorTransferFunction.cxx
Issue History
2012-08-22 04:52John StarkNew Issue
2012-08-23 03:58John StarkFile Added: ColorTransferFn.patch
2012-08-23 03:58John StarkFile Added: ImageMapToColorsBugTest.cxx
2012-08-23 04:00John StarkNote Added: 0029049
2013-04-16 16:43John StarkFile Added: TestColorTransferFunction.cxx
2013-04-16 16:45John StarkNote Added: 0030575
2013-04-17 15:04John StarkNote Edited: 0030575bug_revision_view_page.php?bugnote_id=30575#r579
2013-07-22 20:46Dave DeMarleNote Added: 0031310
2014-08-29 08:42John StarkNote Added: 0033304
2014-09-30 08:44Bill LorensenTag Attached: hackaton
2014-09-30 08:44Bill LorensenAssigned To => Bill Lorensen
2014-09-30 08:44Bill LorensenStatusbacklog => tabled
2014-10-01 12:40Berk GeveciStatustabled => backlog
2016-07-06 16:48Berk GeveciStatusbacklog => expired
2016-07-06 16:48Berk GeveciNote Added: 0036273
2016-08-12 09:55Kitware RobotNote Added: 0037291
2016-08-12 09:55Kitware RobotStatusexpired => closed
2016-08-12 09:55Kitware RobotResolutionopen => moved

Notes
(0029049)
John Stark   
2012-08-23 04:00   
I've uploaded a patch with the CriticalSection fix I used, and a test which exposes the bug on my computer. Sorry, the test is missing the necessary #include's, but it came from a larger test suite.
(0030575)
John Stark   
2013-04-16 16:45   
(edited on: 2013-04-17 15:04)
This is still a problem in the latest master. I uploaded a test that shows the problem at master / 5a986ef5672f139a52188ec267ab3ce2488477af (16 Apr 2013).

Gerrit patch : http://review.source.kitware.com/#/t/2647 [^]

(0031310)
Dave DeMarle   
2013-07-22 20:46   
added myself to reviewer list to help push it through
(0033304)
John Stark   
2014-08-29 08:42   
In writing a test for this I found several other problems with vtkColorTransferFunction:

- In some cases the output depends on whether the input data type was float or uchar, even when the same (integral of course) values are input.
- Opacity (alpha) is handled differently for the float and uchar methods.
- Luminance output is handled differently for the float and uchar methods.

(See http://review.source.kitware.com/#/c/14376/9/Rendering/Core/Testing/Cxx/TestColorTransferFunction.cxx [^])
(0036273)
Berk Geveci   
2016-07-06 16:48   
Setting to status of bugs that have not been updated in the last year to expired. Please re-open if still important.
(0037291)
Kitware Robot   
2016-08-12 09:55   
Resolving issue as `moved`.

This issue tracker is no longer used. Further discussion of this issue may take place in the current VTK Issues page linked in the banner at the top of this page.