From: Leonid Beynenson Date: Tue, 22 May 2012 13:24:37 +0000 (+0000) Subject: Added a check of the DetectionBasedTracker's inner state in the main thread function... X-Git-Tag: accepted/tizen/6.0/unified/20201030.111113~4899 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=32878f85778442846b82f29fbea32cadb935acb0;p=platform%2Fupstream%2Fopencv.git Added a check of the DetectionBasedTracker's inner state in the main thread function of this class. This change should fix a multithread bug in the class. --- diff --git a/modules/contrib/src/detection_based_tracker.cpp b/modules/contrib/src/detection_based_tracker.cpp index 90392e3..bbf27b8 100644 --- a/modules/contrib/src/detection_based_tracker.cpp +++ b/modules/contrib/src/detection_based_tracker.cpp @@ -241,6 +241,11 @@ void DetectionBasedTracker::SeparateDetectionWork::workcycleObjectDetector() CV_Assert(stateThread==STATE_THREAD_WORKING_SLEEPING); pthread_mutex_lock(&mutex); + if (!isWorking()) {//it is a rare case, but may cause a crash + LOGD("DetectionBasedTracker::SeparateDetectionWork::workcycleObjectDetector() --- go out from the workcycle from inner part of lock just before waiting"); + pthread_mutex_unlock(&mutex); + break; + } CV_Assert(stateThread==STATE_THREAD_WORKING_SLEEPING); pthread_cond_wait(&objectDetectorRun, &mutex); if (isWorking()) {