Live555 RTSPServer object destroyed improperly or the library bug?

996 views Asked by At

I have a problem with destroying RTSPServer object: the app crashes with a SIGSEGV Error. But the RTSPServer object might be destroyed only in the case if I do not touch all other objects. Is this a library bug or am I doing something wrong?

Their recent live555 changelog says:

2015.05.12:
- Updated the previous revision to change the order in which fields are deleted 
  in the "RTSPServer" destructor, to avoid a possible crash if "RTSPServer" 
  objects are deleted. (Thanks to ChaSeop Im for noting the problem.)

This is my destructor:

RTSPServerH264::~RTSPServerH264()
{
    LOG(INFO) << "RTSP server close: destroying objects";

    if (mSms.size() > 0)
    {
        LOG(INFO) << "destroying: Server Media Subsession vector";
        for (ServerMediaSession* s : mSms)
        {
            s->deleteAllSubsessions();
            Medium::close(s);
        }
        mSms.clear();
        mLiveSubsession.clear();
    }

    if (mRTSPServer)
    {
        LOG(INFO) << "destroying: RTSPServer";
        // BUG: Destroying RTSPServer object crashes the whole application!
        Medium::close(mRTSPServer);
    }

    if (mUsageEnvironment)
    {
        LOG(INFO) << "destroying: Usage Environment";
        mUsageEnvironment->reclaim();
    }

    if (mTaskScheduler)
    {
        LOG(INFO) << "destroying: Task Scheduler";
        delete mTaskScheduler;
    }
}
1

There are 1 answers

0
Happy Torturer On BEST ANSWER

The answer to my question is now available here: http://lists.live555.com/pipermail/live-devel/2015-June/019490.html

Response text:

I have a problem using Medium::close() in my destructor when deleting an RTSPServer object after I have already deleted ServerMediaSession* objects vector (of course, using Medium::close() too).

First, make sure that you are using the latest version of the software (a bug related to deleting RTSPServer's was fixed in version 2015.06.24).

Second, be aware that once you have added a ServerMediaSession object to a RTSPServer, you must not delete the ServerMediaSession object by calling Medium::close(). Instead, you must use GenericMediaServer::deleteServerMediaSession() (GenericMediaServer is the base class of RTSPServer), so that the RTSPServer is told that the ServerMediaSession object is being deleted.

Finally, however, note that you don’t need to delete ServerMediaSession objects before you delete a RTSPServer, because the RTSPServer destructor will automatically delete any ServerMediaSession (and ClientConnection and ClientSession) objects that it manages. Instead, you can just call Medium::close() on your RTSPServer object.

Ross Finlayson, Live Networks, Inc., http://www.live555.com/