Joachim Wilke wrote:
Hi everyone,
i have experienced some strange behaviour of my plain vanilla vdr. When vdr reaches the end of a replay it segfaults. Core file analysis showed the following backtrace:
#0 cUnbufferedFile::Seek(long, int) (this=0x0, Offset=0, Whence=0) at tools.c:884 #1 0x080dab2c in cFileName::SetOffset(int, int) (this=0xb56a1540, Number=3, Offset=0) at recording.c:1345 #2 0x080dac5d in cFileName::NextFile() (this=0x0) at recording.c:1358 #3 0x0809d8e1 in cDvbPlayer::NextFile(unsigned char, int) (this=0xb56a1540, FileNumber=64 '@', FileOffset=0) at dvbplayer.c:306 #4 0x0809db67 in cDvbPlayer::Action() (this=0x3) at thread.h:94 #5 0x080fce56 in cThread::StartThread(cThread*) (Thread=0x3) at thread.c:234 #6 0xb7fbab63 in start_thread () from /lib/tls/libpthread.so.0
It seems that vdr tries to access a reference to an cUbufferedFile object in cFileName::SetOffset which is a null pointer. The following quick and dirty hack solved the crash, but as I don't know this code deep enough it may have other side effects.
--- recording.c.sav Mon Oct 31 13:27:58 2005 +++ recording.c Tue Nov 1 19:20:27 2005 @@ -1342,7 +1342,7 @@ cUnbufferedFile *cFileName::SetOffset(in // found a non existing file suffix } if (Open() >= 0) {
if (!record && Offset >= 0 && file->Seek(Offset, SEEK_SET) != Offset) {
if (!record && Offset >= 0 && file && file->Seek(Offset,
SEEK_SET) != Offset) { LOG_ERROR_STR(fileName); return NULL; }
Regards, Joachim.
I'd say this isn't just a "quick and dirty hack", it's the actual fix. Before using cUbufferedFile the lseek() just failed when the file handle was -1. Now the pointer is NULL in than case, so the check is necessary.
Thanks for spotting.
Klaus