Page MenuHomePhabricator

WeakPointer: Exception on OnDeleteEvent when closing MITK workbench
Closed, WontfixPublic

Description

OS: Windows (none other OS tested yet)

Description:
When using the mitk::WeakPointer in the QmitkNodeSelectionButton (part of the org.mitk.gui.qt.common plugin). I get a an exception when I am closing the application as soon as I have called mitk::WeakPointer::Lock().

The exception is raised in WeakPointer::OnDeleteEvent()

if (m_DeleteEventCallback)
  m_DeleteEventCallback();

When it tries to call m_DeleteEventCallback.

If I switch the implementation to use a SmartPointer in QmitkNodeSelectionButton everything works fine. But I would like to just use a weak pointer. And maybe this problem also points to more fundamental flaw.

Event Timeline

What is the function you set as DeleteEventCallback?

What is the function you set as DeleteEventCallback?

None. I haven't set one explicitly.

Okay, strange. std::function implements the bool() operator for the check. The only thing I could imagine is that the implementation your toolchain is using, doesn't provide the operator and evaluates to something else. What compiler are you using?

I use VS2017 (windows 10).

One can provoke the violation when

  1. selecting a node
  2. clearing the workspace
  3. closing the view (e.g. Data Storage Viewer Test)

or

  1. selecting a node
  2. closing the view (e.g. Data Storage Viewer Test)
  3. closing the application

The violation is sometimes not provoked if I do the following

  1. selecting a node
  2. closing the view
  3. clearing the workspace
  4. closing the application

(but I had one try, where it crashes at 3).

I think it is some kind of "racing condition" may due to the timing when Qt relay destructs the widgets that has a weak pointer as member.

kislinsk triaged this task as Normal priority.Nov 22 2018, 11:46 AM

Threading issue? Making WeakPointer thread-safe?

Threading issue? Making WeakPointer thread-safe?

That wouldn't contradict the racing condition assumption. Isn't the WeakPointer thread-safe already?

https://itk.org/Doxygen413/html/ThreadingPage.html

I interpret the section about application-level multithreading as "do it yourself in terms of event mechanisms and stuff". So this is still my first guess. We should at least update the WeakPointer documentation or think about if and how we could get it to work anyways.

floca raised the priority of this task from Normal to High.Feb 15 2020, 10:19 AM
floca added a project: Request for Discussion.

@kislinsk mentioned that he noticed some crashes lately when closing the workbench. We should see if they may orgininate from the problem documented in this tasks. And should discuss what the reasons for the problem could be and who to solve it.

kalali lowered the priority of this task from High to Normal.Nov 20 2020, 11:11 AM
kalali removed a project: Request for Discussion.
kislinsk added a project: Auto-closed.

Hi there! 🙂

This task was auto-closed according to our Task Lifecycle Management.
Please follow this link for more information and don't forget that you are encouraged to reasonable re-open tasks to revive them. 🚑

Best wishes,
The MITK devs