Crash with vtkImageReslice GenerateStencilOutputOn() and SetSplitModeToBlock()
This is an issue that can come up when multithreading, if the splitting causes division along the x axis. The reslice filter generates an output stencil (essentially a mask that describes the overlap of its output with its transformed input) by calling the InsertNextExtent() method on the stencil every time it writes a row of data to its output. The problem occurs when a row is split between different pieces.
The stencil's InsertNextExtent() method is thread safe as long as no two threads operate on the same row of the stencil at the same time. The problem is that a stencil row must be built by adding "extents" consecutively, starting with the lowest x index that is inside the stencil. If the extents are added out of order (and this could happen even without multithreading), the resulting data for that stencil row will be corrupt. As a result, any filter that uses the stencil might crash.
Adding a mutex is not a solution, because (a) the problem is not specific to threads and (b) adding a mutex for the whole data structure would kill performance, while adding a mutex for every single row of the stencil would be unreasonable.
The reasonable solutions would be to (1) use thread-local storage to temporarily store the information, and then generate the stencil after the threads rejoin, or (2) simply disallow splitting along x if an output stencil is to be generated.
Currently vtkImageReslice is the only multi-threaded filter that generates a stencil, and is the only filter that runs into this issue.