streamdev-cvs bugs & fixes

Message ID 200503061255.24913.stefan@lucke.in-berlin.de
State New
Headers

Commit Message

Stefan Lucke March 6, 2005, 11:55 a.m. UTC
  Hi,

upon testing of softdevice-cvs in combination with streamdev-cvs I got the
the following errors which could be fixed by attached diffs.

error:
	undefined symbol: _ZN16cMenuWhatsOnItemC1EPK6cEventP8cChannelb
fix:
	streamdev-cvs-client.diff + streamdev-cvs-Makefile.diff

error:
	streamdev-cvs server "pure virtual method called"
fix:
	streamdev-cvs-server.diff

pending bug:
	server does not switch channel upon client request. only channels from
	current (server side) transponder could be selected.

test enviroment:
	vdr-1.3.22 (unpatched, vanilla), softdevice-cvs (from today, xv-out)
  

Comments

Sascha Volkenandt March 6, 2005, 1:25 p.m. UTC | #1
Am Sonntag, 6. März 2005 12:55 schrieb Stefan Lucke:
> error:
> 	streamdev-cvs server "pure virtual method called"
> fix:
> 	streamdev-cvs-server.diff
>
> pending bug:
> 	server does not switch channel upon client request. only channels from
> 	current (server side) transponder could be selected.

Probably these two work together. Your patch doesn't really fix this issue 
(which btw. doesn't happen with gcc 2.95) because still only the base method 
is called (which does nothing now instead of throwing the pure virtual error) 
and not, as it should, the derived method.

I assume this is a compiler bug, since the error should be caught at 
compile-time (I can't see any error though, since the called object is a 
derivation and the method is derived, too). Anyway, if I "shift around" those 
methods a bit, it throws a "pure virtual method" error with gcc 2.95, but not 
with gcc 3.x.


Greetings,
Sascha
  
Stefan Lucke March 6, 2005, 2 p.m. UTC | #2
On Sonntag, 6. März 2005 14:25, Sascha Volkenandt wrote:
> Am Sonntag, 6. März 2005 12:55 schrieb Stefan Lucke:
> > error:
> > 	streamdev-cvs server "pure virtual method called"
> > fix:
> > 	streamdev-cvs-server.diff
> >
> > pending bug:
> > 	server does not switch channel upon client request. only channels from
> > 	current (server side) transponder could be selected.

Setting suspend mode from "offer" to "always" fixed that. Whithout
server output device, I need to place:
streamdev-server.SuspendMode = 1
in setup.conf.

> 
> Probably these two work together. Your patch doesn't really fix this issue 
> (which btw. doesn't happen with gcc 2.95) because still only the base method 
> is called (which does nothing now instead of throwing the pure virtual error) 
> and not, as it should, the derived method.

As cStreamdevStreamer is derived from cThread which in term has no
Detach() Attach() methods, cStreamdevServer should provide those methods.
Yes maybe thats a compiler issue.
gcc --version
gcc (GCC) 3.3.1 (SuSE Linux)

> 
> I assume this is a compiler bug, since the error should be caught at 
> compile-time (I can't see any error though, since the called object is a 
> derivation and the method is derived, too). Anyway, if I "shift around" those 
> methods a bit, it throws a "pure virtual method" error with gcc 2.95, but not 
> with gcc 3.x.
> 
> 
> Greetings,
> Sascha
> 
> 
> _______________________________________________
> vdr mailing list
> vdr@linuxtv.org
> http://www.linuxtv.org/cgi-bin/mailman/listinfo/vdr
>
  
Udo Richter March 6, 2005, 4:37 p.m. UTC | #3
Sascha Volkenandt wrote:
> I assume this is a compiler bug, since the error should be caught at 
> compile-time (I can't see any error though, since the called object is a 
> derivation and the method is derived, too). Anyway, if I "shift around" those 
> methods a bit, it throws a "pure virtual method" error with gcc 2.95, but not 
> with gcc 3.x.

I've seen pure virtual method errors before with cThread's. There is a 
way how these pure virtuals can get active: At destructor time, as soon 
as the derived class is destructed, the virtuals get reverted to the 
pure virtuals of the base class, before the base class destructor takes 
over. Reason is that the derived object is gone as soon as the derived 
destructor ends, and only the base object needs to destruct.

In this case (just a guess by a quick look at source code):
~cStreamdevStreamer() calls Stop(), and Stop() calls Detach(). Since the 
derived cStreamdevLiveStreamer is already destructed, its virtual 
Detach() is gone too, and the pure virtual cStreamdevStreamer::Detach() 
gets called.

Virtuals in destructors are dangerous. Better make sure the thread is 
stopped before the object destructs...

Cheers,

Udo
  
Stefan Lucke March 6, 2005, 5:32 p.m. UTC | #4
On Sonntag, 6. März 2005 17:37, Udo Richter wrote:
> Sascha Volkenandt wrote:
> > I assume this is a compiler bug, since the error should be caught at 
> > compile-time (I can't see any error though, since the called object is a 
> > derivation and the method is derived, too). Anyway, if I "shift around" those 
> > methods a bit, it throws a "pure virtual method" error with gcc 2.95, but not 
> > with gcc 3.x.
> 
> I've seen pure virtual method errors before with cThread's. There is a 
> way how these pure virtuals can get active: At destructor time, as soon 
> as the derived class is destructed, the virtuals get reverted to the 
> pure virtuals of the base class, before the base class destructor takes 
> over. Reason is that the derived object is gone as soon as the derived 
> destructor ends, and only the base object needs to destruct.
> 
> In this case (just a guess by a quick look at source code):
> ~cStreamdevStreamer() calls Stop(), and Stop() calls Detach(). Since the 
> derived cStreamdevLiveStreamer is already destructed, its virtual 
> Detach() is gone too, and the pure virtual cStreamdevStreamer::Detach() 
> gets called.

That's exact that was I've seen when I run vdr from gdb. The line
reported was line 103 from streamer.c : Detach ().

> 
> Virtuals in destructors are dangerous. Better make sure the thread is 
> stopped before the object destructs...
  

Patch

Index: menu.c
===================================================================
RCS file: /var/cvsroot/streamdev/client/menu.c,v
retrieving revision 1.3
diff -U3 -r1.3 menu.c
--- menu.c	8 Feb 2005 17:22:35 -0000	1.3
+++ menu.c	6 Mar 2005 11:42:23 -0000
@@ -250,7 +250,7 @@ 
 public:
   const cEvent *event;
   const cChannel *channel;
-  cMenuWhatsOnItem(const cEvent *Event, cChannel *Channel, bool Now = false);
+  cMenuWhatsOnItem(const cEvent *Event, cChannel *Channel);//, bool Now = false);
 };
 #endif
 
@@ -312,7 +312,7 @@ 
 
 	while (Schedule) {
 		pArray=(const cEventInfo**)realloc(pArray, (num + 1) * sizeof(cEventInfo*));
-		pArray[num] = Now ? Schedule->GetPresentEvent() 
+		pArray[num] = Now ? Schedule->GetPresentEvent()
 				: Schedule->GetFollowingEvent();
 		if (pArray[num]) {
 			cChannel *channel
@@ -335,7 +335,7 @@ 
 
 	free(pArray);
 #else
-  for (cChannel *Channel = Channels.First(); Channel; 
+  for (cChannel *Channel = Channels.First(); Channel;
 			Channel = Channels.Next(Channel)) {
   	if (!Channel->GroupSep()) {
       const cSchedule *Schedule 
@@ -344,7 +344,7 @@ 
         const cEvent *Event = Now ? Schedule->GetPresentEvent() 
 						: Schedule->GetFollowingEvent();
         if (Event)
-          Add(new cMenuWhatsOnItem(Event, Channel), 
+          Add(new cMenuWhatsOnItem(Event, Channel),
 							Channel->Number() == CurrentChannel);
       }
     }