Re: BUG: race condition triggered in cReceiver due to incorrect use by femon

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Reinhard Nissl wrote:
I've just got a pure virtual function call in cDevice::Action() for
receiver[i]->Receive(b, TS_SIZE);

cReceiver::~cReceiver() calls Detach(), but at that time, it is simply
too late as the virtual method table entry for Receive() has already
been restored to 0.

I suggest to call Detach() from cFemonReceiver::~cFemonReceiver() to fix
this issue.

Calling virtual functions from destructors is generally not a good idea. It works if the call is in the deepest nested destructor, but within a base class destructor, virtual functions are already being destructed and reverted to the base class. (here: to a pure virtual dummy)

The best method to avoid this is to do all cleanup involving virtual functions before destroying the object. If this is not possible, it also works to do the cleanup in EVERY derived class' destructor.

This is extremely nasty within a cThread, where you have to make sure that the thread got stopped _before_ the destructor gets called, or you risk to 'steal' the virtual functions from the running thread.

Cheers,

Udo


_______________________________________________
vdr mailing list
vdr@xxxxxxxxxxx
http://www.linuxtv.org/cgi-bin/mailman/listinfo/vdr

[Index of Archives]     [Linux Media]     [Asterisk]     [DCCP]     [Netdev]     [Xorg]     [Util Linux NG]     [Xfree86]     [Big List of Linux Books]     [Fedora Users]     [Fedora Women]     [ALSA Devel]     [Linux USB]

  Powered by Linux