vtkExtractHistogram has as memory access issue when using Calculate Averages
As an example, if we have an input dataset has a range of values from 1.1 to over 100, but then use a custom bin range of 0 to 4, it works just fine. If we then turn on the option for Calculate Averages... then the Y axis values will be something very strange coming out from whatever RAM had when the array was created/asked for.
Attached is the file bottom_928a.vtk, which can be used as a test case for reproducing this issue. The options to be used with vtkExtractHistogram
are as follows (using ParaView's interface out of convenience to set it up):
- Input array:
mag(wallShrearStress)
- Calculate Averages: On
- Show only on the Series Parameters:
Area_total
- Use Custom Bin Ranges:
- If you use 1 to 4, it works just fine.
- If you use 0 to 4, it gives rubbish on the Y axis... either 0, or 1e-72, or 1e+64, or 1e+256...
You can use this save state with ParaView 5.11.1: Works.pvsm
I looked online for similar complaints and found this thread: https://discourse.paraview.org/t/histogram-calculate-average-bug/5100
I inspected the code, to try and deduce the origin of the error, but only managed to figure out that this bug still exists:
- When it was still in ParaView some 4 years ago: https://gitlab.kitware.com/paraview/paraview/-/blob/62bb8893c7ce0e231ed83333da31b804f45421d8/ParaViewCore/VTKExtensions/Core/vtkExtractHistogram.cxx
- When it was transferred to VTK: 3a600732
- In the current master branch: https://gitlab.kitware.com/vtk/vtk/-/blob/master/Filters/Statistics/vtkExtractHistogram.cxx
My current suspicion is that the check within RequestData
:
if (binValues->GetValue(i))
is flawed somehow, possibly because the first bin is never filled in and so it divides by a non-zero garbage value within the if block.
Unfortunately I don't have a development environment ready for VTK+ParaView at the moment, in order to confirm my suspicion.