[Live-devel] OnDemandServerMediaSubsession::deleteStream problem

Igor Bukanov igor at mir2.org
Thu Jun 7 03:37:21 PDT 2007


The current code for OnDemandServerMediaSubsession::deleteStream,
http://live555.com/liveMedia/doxygen/html/classOnDemandServerMediaSubsession.html#55a633f69121ee4f71874003d422f41c
calls streamState->endPlaying even when destination is null. This
immediately segfaults in endPlaying on null dereference.

I observe this pretty reliably when OnDemandServerMediaSubsession is
used in a video server implementation when the same source is unicasts
to several VLC. When all VLC processes crashes when decoding
particular MPEG4 frame almost at the same time this eventually leads
to that  deleteStream calls with already removed clientSessionId.

The attached patch fixes that via skipping calls to
streamState->endPlaying with unknown clientSessionId.

Regards, Igor

Index: OnDemandServerMediaSubsession.cpp
===================================================================
RCS file: /var/cvsroot/repos1/videoserver/external/live/liveMedia/OnDemandServerMediaSubsession.cpp,v
retrieving revision 1.1
diff -U7 -p -r1.1 OnDemandServerMediaSubsession.cpp
--- OnDemandServerMediaSubsession.cpp	29 May 2007 11:35:10 -0000	1.1
+++ OnDemandServerMediaSubsession.cpp	7 Jun 2007 10:17:31 -0000
@@ -295,24 +295,25 @@ void OnDemandServerMediaSubsession::setS
   if (streamState != NULL && streamState->mediaSource() != NULL) {
     setStreamSourceScale(streamState->mediaSource(), scale);
   }
 }

 void OnDemandServerMediaSubsession::deleteStream(unsigned clientSessionId,
 						 void*& streamToken) {
+  StreamState* streamState = (StreamState*)streamToken;
+
   // Look up (and remove) the destinations for this client session:
   Destinations* destinations
     = (Destinations*)(fDestinationsHashTable->Lookup((char
const*)clientSessionId));
   if (destinations != NULL) {
     fDestinationsHashTable->Remove((char const*)clientSessionId);
-  }

-  // Stop streaming to these destinations:
-  StreamState* streamState = (StreamState*)streamToken;
-  if (streamState != NULL) streamState->endPlaying(destinations);
+    // Stop streaming to these destinations:
+    if (streamState != NULL) streamState->endPlaying(destinations);
+  }

   // Delete the "StreamState" structure if it's no longer being used:
   if (streamState != NULL && streamState->referenceCount() >= 0) {
     if (streamState->referenceCount() > 0) --streamState->referenceCount();
     if (streamState->referenceCount() == 0) {
       delete streamState;
       if (fLastStreamToken == streamToken) fLastStreamToken = NULL;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: OnDemandServerMediaSubsession.patch
Type: application/octet-stream
Size: 1740 bytes
Desc: not available
Url : http://lists.live555.com/pipermail/live-devel/attachments/20070607/1e8fb169/attachment.obj 


More information about the live-devel mailing list