Has anybody already tried to use helgrind on vdr?
(helgrind is a valgrind variant for searching threading bugs, see http://valgrind.org/docs/manual/hg_main.html#hg-top)
There are several places in vdr (and in muggle) where helgrind says it found something.
One of them is in cRemote. This might be one of the easier cases for finding out whether helgrind reports valid bugs for vdr - and for me learning about threading problems.
cRemote::Put() and cRemote::Get() use a mutex but cRemote::HasKeys() does not. Could that be a bug? If I change HasKeys(), helgrind stays silent:
bool cRemote::HasKeys(void) { cMutexLock MutexLock(&mutex); return in != out && !(keys[out] & k_Repeat); }
Without that mutex, I believe cInterface::GetKey can call Skins.Flush() even if there actually is a key. With the mutex, this still seems possible but more seldom. Is this analysis correct? If yes, how could that last hole be fixed?
If you want to I will post more messages from helgrind about other problems but I first want to be sure this makes sense. Amongst others, helgrind sees problems in the EPG code, in cList handling and in the remote plugin.
Some messages from helgrind about cRemote:
==16960== Possible data race reading variable at 0x81E15C0 (cRemote::in) ==16960== at 0x80EA117: cRemote::HasKeys() (remote.c:148) ==16960== by 0x80B3DE0: cInterface::GetKey(bool) (interface.c:34) ==16960== by 0x8118A28: main (vdr.c:647) ==16960== Address 0x81E15C0 is in BSS section of /home/vdr/vdr-1.3.22/vdr ==16960== Previous state: shared RW, locked by:0x81E15D0(cRemote::mutex) ==16960== ==16960== Possible data race reading variable at 0x81E15C4 (cRemote::out) ==16960== at 0x80EA119: cRemote::HasKeys() (remote.c:148) ==16960== by 0x80B3DE0: cInterface::GetKey(bool) (interface.c:34) ==16960== by 0x8118A28: main (vdr.c:647) ==16960== Address 0x81E15C4 is in BSS section of /home/vdr/vdr-1.3.22/vdr ==16960== Previous state: shared RW, locked by:0x81E15D0(cRemote::mutex) ==16960== ==16960== Possible data race reading variable at 0x81E1580 (cRemote::keys) ==16960== at 0x80EA130: cRemote::HasKeys() (remote.c:148) ==16960== by 0x80B3DE0: cInterface::GetKey(bool) (interface.c:34) ==16960== by 0x8118A28: main (vdr.c:647) ==16960== Address 0x81E1580 is in BSS section of /home/vdr/vdr-1.3.22/vdr ==16960== Previous state: shared RW, locked by:0x81E15D0(cRemote::mutex) ==16960==