PATCH: Re: [mythtv] Segfault + BT: Race condition in filtermanager

Ed Wildgoose lists at wildgooses.com
Fri Jun 25 08:05:11 EDT 2004


Ed Wildgoose wrote:

> I'm still trying to track down the segfault that I repeatedly see when 
> video changes aspect ratio from 4:3 to 16:9.  At last with the latest 
> GDB I seem to be able to get a clean backtrace, and as you can see it 
> rather seems to point to something happening in the video playback 
> loop before the filter manager manages to get everything reinitialised 
> in ReInitVideo


Aha, a lightbulb goes on.  I was misled by where GDB seemed to be 
telling me where the segfault was.  The filter variable is not locked 
and used by two threads.  The attached patch fixes this for me.

What's pecualiar is why no one else has seen this?  It should have been 
hitting a lot of people really?

Please apply to cvs

Ed W
-------------- next part --------------
Index: NuppelVideoPlayer.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythtv/libs/libmythtv/NuppelVideoPlayer.cpp,v
retrieving revision 1.347
diff -u -r1.347 NuppelVideoPlayer.cpp
--- NuppelVideoPlayer.cpp	11 Jun 2004 03:16:53 -0000	1.347
+++ NuppelVideoPlayer.cpp	25 Jun 2004 11:49:06 -0000
@@ -598,6 +602,8 @@
     VideoFrameType otmp = FMT_YV12;
     int btmp;
 
+    videofilters_lock.lock();
+    
     if (videoFilters)
         delete videoFilters;
 
@@ -605,6 +611,8 @@
     postfilt_height = video_height;
     videoFilters = FiltMan->LoadFilters(videoFilterList, itmp, otmp, 
                                         postfilt_width, postfilt_height, btmp);
+					
+    videofilters_lock.unlock();
 }
 
 int NuppelVideoPlayer::tbuffer_numvalid(void)
@@ -1735,7 +1743,9 @@
             video_actually_paused = true;
             videoThreadPaused.wakeAll();
 
+            videofilters_lock.lock();
             videoOutput->ProcessFrame(NULL, osd, videoFilters, pipplayer);
+            videofilters_lock.unlock();
             videoOutput->PrepareFrame(NULL); 
             videoOutput->Show(m_scan);
             ResetNexttrigger(&nexttrigger);
@@ -1774,7 +1784,9 @@
         if (cc)
             ShowText();
 
+        videofilters_lock.lock();
         videoOutput->ProcessFrame(frame, osd, videoFilters, pipplayer);
+        videofilters_lock.unlock();
 
         if (usevideotimebase)
             VTAVSync();
@@ -1824,13 +1836,17 @@
         if (pausevideo)
         {
             videoThreadPaused.wakeAll();
+            videofilters_lock.lock();
             videoOutput->ProcessFrame(NULL, osd, videoFilters, pipplayer);
+            videofilters_lock.unlock();
         }
         else
         {
             if (cc)
                 ShowText();
+            videofilters_lock.lock();
             videoOutput->ProcessFrame(NULL, osd, videoFilters, pipplayer);
+            videofilters_lock.unlock();
         }
 
         usleep(delay);
Index: NuppelVideoPlayer.h
===================================================================
RCS file: /var/lib/mythcvs/mythtv/libs/libmythtv/NuppelVideoPlayer.h,v
retrieving revision 1.145
diff -u -r1.145 NuppelVideoPlayer.h
--- NuppelVideoPlayer.h	2 Jun 2004 03:45:28 -0000	1.145
+++ NuppelVideoPlayer.h	25 Jun 2004 11:49:07 -0000
@@ -286,6 +286,8 @@
     QMutex prebuffering_lock;
     QWaitCondition prebuffering_wait;
 
+    QMutex videofilters_lock; // Lock filters while we rebuild them or use them
+
     /* Text circular buffer */
     int wtxt;          /* next slot to write */
     int rtxt;          /* next slot to read */


More information about the mythtv-dev mailing list