﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	severity	resolution	keywords	cc	mlocked
1716	Decoder locking in NuppelVideoPlayer	dm@…	Isaac Richards	"I have noticed a number of crashes in the frontend when changing channels but hadn't been able to pin it down to anything until it happened last week when I was running under gdb.  I managed to get a backtrace (attached) but I've since investigated it a bit further.  The crash happened in a function called from NuppelVideoPlayer::SetWatchingRecording and it appeared that the decoder object had changed under the feet of the function.  

{{{
(gdb) up
#5  0x00b25d04 in NuppelVideoPlayer::SetWatchingRecording (this=0x8e986b8,
    mode=false) at NuppelVideoPlayer.cpp:338
338             GetDecoder()->setWatchingRecording(mode);
(gdb) print decoder
$22 = (class DecoderBase *) 0xa96028f0
(gdb) down
#4  0x00b5e94e in DecoderBase::setWatchingRecording (this=0xaa31a4d8,
    mode=false) at decoderbase.cpp:95
95              SyncPositionMap();
(gdb) print this
$23 = (DecoderBase * const) 0xaa31a4d8
}}}

It seems that NVP creates a new thread that at some point calls SetDecoder to update the decoder but there is no locking to ensure that another thread is not using the decoder object.  I wanted to confirm that there really was a problem so the attached patch contains calls to sleep and printf to demonstrate the problem.  There's also the beginnings of a fix although someone who knows the code better may well come up with something better.  There may be other functions that need to lock the decoder object.

David.
"	defect	closed	minor	unknown	mythtv		medium	fixed			0
