The crash/incorrect selection is a caused by a memory corruption bug in the example. vtkHardwareSelector.SetArea
gets (x,y) as bottom-right pixel, which is outside of the valid range (x-1, y-1). To fix it, change
hsel.SetArea(0, 0, x, y)
to
hsel.SetArea(0, 0, x-1, y-1)