There was an array out of bounds when interacting with vtkLabelPlacementMapper

Hi all,I used vtkStringArray, vtkPointSetToLabelHierarchy, and vtkLabelPlacementMapper to display the cell number, which worked fine, but occasionally crashed when rotating the camera.
Has anyone experienced the same problem? How did the problem arise and how can I avoid it?

We had a similar problem when we migrated to VTK9.
This was for a vtkCaptionWidget object.
Some of our older code used New() and Delete() for this object.
The resolution was to call Off() before calling Delete(). For VTK8 and earlier, this was not necessary.
As in your case, the crash occurred during interaction. The call stack at that time provided no clue as to what the problem was.

Here is a quote from VTK: vtkObject Class Reference
“If the callback is a member of a vtkObjectBase-derived object, then the callback will automatically be disabled if the object destructs (but the observer will not automatically be removed). If the callback is a member of any other type of object, then the observer must be removed before the object destructs or else its dead pointer will be used the next time the event occurs.”