Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: MythTV: Commits

Ticket #7614: Segfault can occur in TVRec::StartRecording()

 

 

MythTV commits RSS feed   Index | Next | Previous | View Threaded


mythtv at cvs

Nov 19, 2009, 12:53 AM

Post #1 of 4 (422 views)
Permalink
Ticket #7614: Segfault can occur in TVRec::StartRecording()

#7614: Segfault can occur in TVRec::StartRecording()
------------------------------------+---------------------------------------
Reporter: david.madsen@… | Owner: danielk
Type: defect | Status: new
Priority: minor | Milestone: unknown
Component: MythTV - Recording | Version: head
Severity: medium | Mlocked: 0
------------------------------------+---------------------------------------
A potential segfault exists in the TVRec::StartRecording() function. This
function creates an iterator to the pendingRecordings QMap. It then
yields to the EventThread to process any outstanding events before
proceeding.

In the event thread it is possible that the call to
TVRec::HandlePendingRecordings() will find a stale recording pending and
will proceed to free the memory used by the info pointer and then delete
the entry out of the pendingRecordings map.

Eventually we will return to execution in the TVRec::StartRecording()
function and we will continue to use the existing iterator. The iterator
itself will still be valid since we are looking at a previously made copy
of the QMap but since the TVRec::HandlePendingRecordings() call deleted
the data stored at the info pointer this code will cause a segfault.
{{{
if (is_busy && !sourceid)
{
mplexid = (*it).info->GetMplexID();
sourceid = (*it).info->sourceid;
}
}}}
I've attached a patch that simply re-executes the find after being awaken
by the EventThread. Since the stale entry has now been deleted the
following loop will not try to dereference the invalid pointer.

--
Ticket URL: <http://svn.mythtv.org/trac/ticket/7614>
MythTV <http://www.mythtv.org/>
MythTV
_______________________________________________
mythtv-commits mailing list
mythtv-commits [at] mythtv
http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-commits


mythtv at cvs

Nov 19, 2009, 6:35 AM

Post #2 of 4 (383 views)
Permalink
Re: Ticket #7614: Segfault can occur in TVRec::StartRecording() [In reply to]

#7614: Segfault can occur in TVRec::StartRecording()
------------------------------------+---------------------------------------
Reporter: david.madsen@… | Owner: danielk
Type: defect | Status: closed
Priority: minor | Milestone: unknown
Component: MythTV - Recording | Version: head
Severity: medium | Resolution: fixed
Mlocked: 0 |
------------------------------------+---------------------------------------
Changes (by danielk):

* status: new => closed
* resolution: => fixed


Comment:

(In [22861]) Fixes #7614. Fixes a segfault with patch by David Madsen, see
ticket for details.

--
Ticket URL: <http://svn.mythtv.org/trac/ticket/7614#comment:1>
MythTV <http://www.mythtv.org/>
MythTV
_______________________________________________
mythtv-commits mailing list
mythtv-commits [at] mythtv
http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-commits


mythtv at cvs

Nov 19, 2009, 6:42 AM

Post #3 of 4 (385 views)
Permalink
Re: Ticket #7614: Segfault can occur in TVRec::StartRecording() [In reply to]

#7614: Segfault can occur in TVRec::StartRecording()
------------------------------------+---------------------------------------
Reporter: david.madsen@… | Owner: danielk
Type: defect | Status: closed
Priority: minor | Milestone: unknown
Component: MythTV - Recording | Version: head
Severity: medium | Resolution: fixed
Mlocked: 0 |
------------------------------------+---------------------------------------

Comment(by danielk):

(In [22862]) Refs #7614. Backport [22861]. Simple fix for a segfault.

--
Ticket URL: <http://svn.mythtv.org/trac/ticket/7614#comment:2>
MythTV <http://www.mythtv.org/>
MythTV
_______________________________________________
mythtv-commits mailing list
mythtv-commits [at] mythtv
http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-commits


mythtv at cvs

Nov 19, 2009, 7:16 PM

Post #4 of 4 (377 views)
Permalink
Re: Ticket #7614: Segfault can occur in TVRec::StartRecording() [In reply to]

#7614: Segfault can occur in TVRec::StartRecording()
------------------------------------+---------------------------------------
Reporter: david.madsen@… | Owner: danielk
Type: defect | Status: closed
Priority: minor | Milestone: unknown
Component: MythTV - Recording | Version: head
Severity: medium | Resolution: fixed
Mlocked: 0 |
------------------------------------+---------------------------------------

Comment(by anonymous):

Do we need to update the value of cancelNext after updating the iterator?
If not it may not match the value from the new pending recording. That
seems like it would be bad:


{{{
// Rescan pending recordings since the event loop may have deleted
// a stale entry. If this happens the info pointer will not be valid
// since the HandlePendingRecordings loop will have deleted it.
it = pendingRecordings.find(cardid);
+ if (it != pendingRecordings.end())
+ cancelNext = (*it).canceled;

}}}

--
Ticket URL: <http://svn.mythtv.org/trac/ticket/7614#comment:3>
MythTV <http://www.mythtv.org/>
MythTV
_______________________________________________
mythtv-commits mailing list
mythtv-commits [at] mythtv
http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-commits

MythTV commits RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.