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;
}
}
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 anRTSPServer
object after I have already deletedServerMediaSession*
objects vector (of course, usingMedium::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 aRTSPServer
, you must not delete theServerMediaSession
object by callingMedium::close()
. Instead, you must useGenericMediaServer::deleteServerMediaSession()
(GenericMediaServer
is the base class ofRTSPServer
), so that theRTSPServer
is told that theServerMediaSession
object is being deleted.Finally, however, note that you don’t need to delete
ServerMediaSession
objects before you delete aRTSPServer
, because theRTSPServer
destructor will automatically delete anyServerMediaSession
(andClientConnection
andClientSession
) objects that it manages. Instead, you can just callMedium::close()
on yourRTSPServer
object.Ross Finlayson, Live Networks, Inc., http://www.live555.com/