Page MenuHomePhabricator

[Segmentation] Loading a segmentation while the Segmentation View is open may lead to a crash
Closed, ResolvedPublic

Description

Crash:

  • Start the Workbench
  • Open the Segmentation View
  • Open an image
  • Create a segmentation
  • Save that segmentation
  • Close the project
  • Open that segmentation again

The crash is only happening in this and pretty similar scenarios. The saved files are fine and can be opened without any issue outside of this scenario. For example, you can break the circle by simply closing the Segmentation View before opening the segmentation again.

This task was initially reported (disguised as pull request) on Github by Petr Henyš.

Revisions and Commits

Related Objects

Event Timeline

kislinsk created this task.

The crash happens in mitk::SliceNavigationController::GetSelectedTimeStep() as m_Time (mitk::Stepper::Pointer) is accessed while it is a nullptr. The events that lead to this situation are that the mitk::ToolManager notifies QmitkSlicesInterpolator via OnToolManagerWorkingDataModified(). This method calls SetCurrentContourListID() in turn, which executes the crashing line of code:

const auto timePoint = m_LastSNC->GetSelectedTimePoint()
GetSelectedTimeStep() GetTime() m_Time->GetPos()

The interesting part here is that m_Time of mitk::BaseController is not supposed to be nullptr in particular as m_Slice is a valid stepper. My first guess is that a partly deconstructed controller is triggered here.

Shortcut to reproduce the crash:

  • Start the Workbench
  • If not already opened, open the Segmentation View
  • Close the project or close the Standard Display
  • Load any segmentation

Reason:

  • In QmitkSegmentationView::RenderWindowPartActivated(), QmitkSlicesInterpolator::Initialize() is called with a list of raw pointers to mitk::SliceNavigationControllers, which in turn saves these raw pointers
  • When the Standard Display is closed, QmitkSegmentationView::RenderWindowPartDeactivated() does not call QmitkSlicesInterpolator::Uninitialize()
  • QmitkSlicesInterpolator still holds raw pointers to the controllers that were destructed when the StandardDisplay was closed, which causes the crash when accessed later on
kislinsk added a revision: Restricted Differential Revision.Nov 8 2022, 5:27 AM