Debugging application crash

I am in process of merging our organization’s SW pipeline based on top of Slicer-4.11 into Slicer-5.10. While I am able to merge and resolve merge conflicts, my application is crashing on startup. I was following the startup routines from,



qSlicerApplicationHelper::postInitializeApplication

if (enableMainWindow)
{
window.reset(new SlicerMainWindowType); <----
}

So far I am able to trace the crash until this function, this→Modified() call:

//----------------------------------------------------------------------------
void vtkMRMLSliceLogic::SetSliceNode(vtkMRMLSliceNode* newSliceNode)
{
  if (this->SliceNode == newSliceNode)
  {
    return;
  }

  // Observe the slice node for general properties like slice visibility.
  // But the slice layers will also notify us when things like transforms have
  // changed.
  // This class takes care of passing the one slice node to each of the layers
  // so that users of this class only need to set the node one place.
  vtkSetAndObserveMRMLNodeMacro(this->SliceNode, newSliceNode);

  this->UpdateSliceCompositeNode();

  for (LayerListIterator iterator = this->Layers.begin(); iterator != this->Layers.end(); ++iterator)
  {
    vtkMRMLSliceLayerLogic* layer = *iterator;
    if (layer != nullptr)
    {
      layer->SetSliceNode(newSliceNode);
    }
  }

  this->Modified();   <----
}

I further traced this to this function:

//---------------------------------------------------------------------------
void vtkMRMLAbstractLogic::Modified()
{
  if (this->GetDisableModifiedEvent())
  {
    ++this->Internal->ModifiedEventPending;
    return;
  }
  this->Superclass::Modified();
}

I understand this→Superclass::Modified() is a call routines connected to observers. But I am not able to find what routines this caller calls which is causing the crash. Some hints I was able to find were,

1- It crashes on setting first vtk MRML slice node ‘Red’.

2- I believe the invoke event that triggers crash is vtkCommand::ModifiedEvent. I find this in vtkObject clas, function, vtkTypeBool vtkSubjectHelper::InvokeEvent(unsigned long event, void* callData, vtkObject* self) in call elem->Command->Execute(self, event, callData);. The event# is 33.

I wanted to ask is there a way to find what routines the callback calls that can be checked for possible crash.

Have you hooked up a debugger to get a stack trace? The observer pattern means that code dynamically adds callback functions to be called when data is modified, and from there many things can happen and your code needs to be careful not to get in an event loop or work with data that isn’t yet fully configured.

Hi Pieper, I am thinking to hookup debugger but currently I am in release mode so will have to build in debug mode. For now, is there any way to know which functions are using callback for a ModifiedEvent, it should be statically defined (hardcoded) instead of dynamic?