[haiku-commits] BRANCH waddlesplash-github.tracker_cleanup_threads_properly [9749bc4c0ab9] src/kits/tracker

  • From: waddlesplash-github.tracker_cleanup_threads_properly <community@xxxxxxxxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Sat, 29 Apr 2017 22:30:32 +0200 (CEST)

added 1 changeset to branch 
'refs/remotes/waddlesplash-github/tracker_cleanup_threads_properly'
old head: 0000000000000000000000000000000000000000
new head: 9749bc4c0ab95598941a5a5909f28e6074001c8c
overview: https://github.com/waddlesplash/haiku/compare/9749bc4c0ab9

----------------------------------------------------------------------------

9749bc4c0ab9: Tracker: Work towards fixing #13371
  
  One of the crash symptoms is fixed, the other one (looks like a 
use-after-free?)
  is not. I need to run this through libroot_debug, probably, but I don't have 
time
  for that right now.

                              [ Augustin Cavalier <waddlesplash@xxxxxxxxx> ]

----------------------------------------------------------------------------

Commit:      9749bc4c0ab95598941a5a5909f28e6074001c8c
Author:      Augustin Cavalier <waddlesplash@xxxxxxxxx>
Date:        Sat Apr 29 20:24:57 2017 UTC

Ticket:      https://dev.haiku-os.org/ticket/13371

----------------------------------------------------------------------------

1 file changed, 16 insertions(+), 1 deletion(-)
src/kits/tracker/PoseView.cpp | 17 ++++++++++++++++-

----------------------------------------------------------------------------

diff --git a/src/kits/tracker/PoseView.cpp b/src/kits/tracker/PoseView.cpp
index 77d13fe..5e6d147 100644
--- a/src/kits/tracker/PoseView.cpp
+++ b/src/kits/tracker/PoseView.cpp
@@ -290,6 +290,13 @@ BPoseView::BPoseView(Model* model, uint32 viewMode)
 
 BPoseView::~BPoseView()
 {
+       std::set<thread_id> addPosesThreads(fAddPosesThreads);
+       fAddPosesThreads.clear(); // This will prompt the threads to exit
+       std::set<thread_id>::iterator it;
+       for (it = addPosesThreads.begin(); it != addPosesThreads.end(); it++)
+               wait_for_thread(*it, NULL);
+       printf("exitOK\n");
+
        delete fPoseList;
        delete fFilteredPoseList;
        delete fVSPoseList;
@@ -1303,6 +1310,14 @@ class AutoLockingMessenger {
                        return hasLock;
                }
 
+               bool LockWithTimeout(bigtime_t timeout)
+               {
+                       if (!hasLock)
+                               hasLock = 
(messenger.LockTargetWithTimeout(timeout) == B_OK);
+
+                       return hasLock;
+               }
+
                bool IsLocked() const
                {
                        return hasLock;
@@ -1434,7 +1449,7 @@ BPoseView::AddPosesTask(void* castToParams)
 
                        // before we access the pose view, lock down the window
 
-                       if (!lock.Lock()) {
+                       if (!lock.LockWithTimeout(1000000)) {
                                PRINT(("failed to lock\n"));
                                posesResult->fCount = modelChunkIndex + 1;
                                throw failToLock();


Other related posts: