[Live-devel] patch for stackoverflow

Erwin Beckers e.beckers at gmail.com
Fri Oct 27 02:02:58 PDT 2006


Hi,

I'm using the LiveMedia555 library and compiled it under Windows XP using
Visual Studio 2005
With this environment i sometimes received a stackoverflow when using the
library to receive a RTSP stream which contains a MPEG-2 TS stream
Fortunaly i found out what causes it and this is the fix i'm using.

The problem is that:
1. MultiFramedRTPSource::doGetNextFrame1() is called
2. in this method afterGetting(this); is called
3. afterGetting(this) does a lot, but in the end it calls continuePlaying()
which again calls MultiFramedRTPSource::doGetNextFrame()
4. MultiFramedRTPSource::doGetNextFrame() again calls
MultiFramedRTPSource::doGetNextFrame1()
which can lead to the stack overflow.

I added a simple boolean to check if we're already in doGetNextFrame1() and
ifso, i simply return.
Not sure if this is the best way todo it, but it works for me

static bool bInDoGetNextFrame1=false;
void MultiFramedRTPSource::doGetNextFrame1() {
    if (bInDoGetNextFrame1) return;

    bInDoGetNextFrame1=true;
    while (fNeedDelivery) {
    .....

Another thing i noticed is that many pointers,buffers,variables are not
initialized correctly in the constructors.
The library assumed that the compiler initializes all variables to 0 but
this is not the case
when using visual studio in debug mode. In debug mode the compiled
initializes all variabled with the value 0xcd
which is especially done to detect un-initialized vars.
Perhaps it would be better to initialize all variables,buffers,pointers in
the constructors

Regards

Erwin Beckers
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.live555.com/pipermail/live-devel/attachments/20061027/bf9a3064/attachment-0001.html 


More information about the live-devel mailing list