[haiku-bugs] [Haiku] #12050: Tracker deadlock between FS unmount and DoPeriodicUpdate

  • From: "mmlr" <trac@xxxxxxxxxxxx>
  • Date: Sat, 02 May 2015 15:22:07 -0000

#12050: Tracker deadlock between FS unmount and DoPeriodicUpdate
Reporter: mmlr | Owner: nobody
Type: bug | Status: new
Priority: normal | Milestone: Unscheduled
Component: Applications/Tracker | Version: R1/Development
Keywords: | Blocked By:
Blocking: | Has a Patch: 0
Platform: All |
Periodic update BPose's are ones that get updated periodically through
TTracker::Pulse() like the volume icons on the desktop with their free
space bars. They are kept in a list managed by a global
PeriodicUpdatePoses object.

TTracker::Pulse() calls PeriodicUpdatePoses::DoPeriodicUpdate()
(Utilities.cpp:222) which locks the PeriodicUpdatePoses object and then
locks the looper of each BPoseView where a BPose is to be updated.

When a volume is unmounted the FS notification triggers the BPose
representing the volume on the desktop to be removed and destroyed. The
BPose destructor then removes itself from the list via
PeriodicUpdatePoses::RemovePose() (Utilities.cpp:200). This goes through
the list and when it finds the item, it locks the object and removes the
BPose. Locking is broken because items are added to the list without
locking and the list traversal on remove doesn't happen locked. This
should be fixed as well but doesn't affect the deadlock here.

The deadlock happens when DoPeriodicUpdate already holds the lock of
PeriodicUpdatePoses but hasn't yet locked the looper of the BPoseView
while the FS notification is handled (which means the looper is locked)
but hasn't yet caused PeriodicUpdatePoses::RemovePose() to be called.

Attached is a KDL session showing more details. As I am tracking other
issues currently and am unsure how this could be fixed cleanly, I'll leave
this here without intention of fixing it myself.

Ticket URL: <https://dev.haiku-os.org/ticket/12050>
Haiku <https://dev.haiku-os.org>
Haiku - the operating system.

Other related posts: