[Live-devel] Destroying RTSPServer object crashes the whole application with SIGSEGV error

adunaevsky at core12.ru adunaevsky at core12.ru
Sat Jun 27 08:45:37 PDT 2015


Hello, Ross Finlayson and LIVE555 support!

First of all, thanks for such a great library. I am developing an application for streaming cv::Mat over RTSP

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). 
The app crashes with SIGSEGV error. 

On the other side, destroying RTSPServer object will succeed if I put it right before destroying ServerMediaSession* objects vector, but this time Medium::close() for ServerMediaSession* will crash my app again with SIGSEGV error. 
What's more interesting: in this case I am still able to use ServerMediaSession* object even after destroying the RTSPServer using Medium::close(), for example, calling the mSms[i] object by method like this: 
  mSms[0]->deleteAllSubsessions() will not cause the crash. 
It means that mSms[0] object still exists after Medium::close(mRTSPServer), but Medium::close(mSms[0]) is not able to destroy it properly, without SIGSEGV errors.

It appears that I have to use Medium::close() either RTSPServer object or a ServerMediaSession* objects vector. Why? Is this a bug or am I doing something wrong?  

Here is my destructor code:
-------------------------------------------------------------------------------------------------------------------------------
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;
    }
}
-------------------------------------------------------------------------------------------------------------------------------

Earlier, I published this issue on stackoverflow but wasn't lucky to get any response:
http://stackoverflow.com/questions/31006804/live555-rtspserver-object-destroyed-improperly-or-the-library-bug
I've read about the RTSPServer bug from the changelog.txt before, that's why I've tested using the latest version of LIVE555 (on Ubuntu 14.04).

-------------------------------------------------------------------------------------------------------------------------------
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.)
-------------------------------------------------------------------------------------------------------------------------------

Best Regards,
Alexander Dunaevsky


More information about the live-devel mailing list