fetzerch/xbmc-pvr-addons — pull request #145 by fetzerch (2013-10-17 21:30:22+00:00)
Title: [mythtv-cmyth] Return shared pointers in MythScheduleManager

In the current implementation, MythScheduleManager holds the upcoming
recordings and recording rules in data structures that use smart
pointers. However, these were always passed as raw pointers to the
outside (pvrclient-mythtv).

With this patch, the API of the MythScheduleManager is changed to always pass
data within smart pointers.

In rare cases, PVRClientMythTV::GetTimers() gets called while
m_scheduleManager->Update() is still running. Update() cleared the list
of upcoming recordings which deleted all MythProgramInfos since the only
reference was held from the list. This could lead into GetTimers
accessing freed memory.

Trace:
0x4809f534 in cmyth_proginfo_start () from
/usr/lib/xbmc/addons/pvr.mythtv.cmyth/XBMC_MythTV_cmyth.pvr
0 0x4809f534 in cmyth_proginfo_start () from
/usr/lib/xbmc/addons/pvr.mythtv.cmyth/XBMC_MythTV_cmyth.pvr
1 0x48076ba8 in MythProgramInfo::StartTime (this=)
at src/cppmyth/MythProgramInfo.cpp:147
2 0x4805ab9c in PVRClientMythTV::GetTimers (this=,
handle=) at src/pvrclient-mythtv.cpp:934
3 0x004dc6b4 in PVR::CPVRClient::GetTimers(PVR::CPVRTimers*) ()
4 0x004ebaec in PVR::CPVRClients::GetTimers(PVR::CPVRTimers*) ()
5 0x00bdb668 in PVR::CPVRTimers::Update() ()
0x00bb5830 in PVR::CPVRManager::ExecutePendingJobs() ()
7 0x00bbae00 in PVR::CPVRManager::Process() ()
8 0x00ebc39c in CThread::Action() ()
9 0x00ebce30 in CThread::staticThread(void*) ()
10 0x405b2a90 in start_thread () from /lib/libpthread.so.0
11 0x41226fb8 in clone () from /lib/libc.so.6

@janbar: Maybe you remember, some time ago I told you about a very rare crash that I experience. with the ScheduleManager. I still don't have an easy way to reproduce it unfortunately.
But it has been reported also here: http://forum.xbmc.org/showthread.php?tid=173932&pid=1529167#pid1529167 I tried to find a solution. I'll do a bit more testing and merge it then.