[mythtv-commits] Ticket #4301: r15020 causes backend segfault on startup

MythTV mythtv at cvs.mythtv.org
Sun Dec 9 22:12:23 UTC 2007


#4301: r15020 causes backend segfault on startup
---------------------------------+------------------------------------------
 Reporter:  mythtv at dadeos.co.uk  |       Owner:  dblain 
     Type:  defect               |      Status:  new    
 Priority:  minor                |   Milestone:  unknown
Component:  upnp                 |     Version:  unknown
 Severity:  medium               |     Mlocked:  0      
---------------------------------+------------------------------------------
 mythbackend segfaults on startup post r15020 with the error:

 QThread object destroyed while thread is still running.

 The attached patch resolves the issue for me.

 I believe that the specific issue was that the SSDP::RequestTerminate()
 function contained a QThread::wait(500) call (which is wait 0.5 seconds
 for the thread to exit) but the SSDP::run() function (the thread loop)
 contains a blocking "select" call with a timeout of 1 second, meaning the
 probability of the thread still executing (waiting for a second) is very
 high when the object is deleted.

 So, the specific bug fix is actually to remove the timeout from the
 QThread::wait() calls. The other changes in the patch are other things I
 noticed whilst investigating the code. Specifically:

 * Mark m_bTermRequested members as "volatile"; Which instructs the
 compiler that their values may change outside of the normal flow of
 control (because they are accessed by two separate threads)

 * Eliminated IsTermRequested?() member functions; replacing these with
 direct references to the m_bTermRequested member variables. There is no
 point in protecting read accesses to these members by mutexs because doing
 so will make no difference to the results, it merely adds overhead.

 * Eliminated mutex locking in Task::Task(), this wasn't doing anything
 useful.

 * Eliminated RequestTerminate?() member functions; It didn't strike me as
 sensible to enforce callers to have to call extra functions on an object
 prior to destroying it (and introducing the possibilities of callers
 failing to call these important functions) this functionality should
 reside in the class' destructors.

-- 
Ticket URL: <http://svn.mythtv.org/trac/ticket/4301>
MythTV <http://svn.mythtv.org/trac>
MythTV


More information about the mythtv-commits mailing list