Hi there, I've found that FG crashes at exit at very high likelihood. Attached is a patch (for Main/globals.cxx) to fix this. Please commit this change.
The cause of the crash is that some subsystems (input and gui) call
get_subsystems() at their destructor.
This is very dangerous since SGSubSystemMgr::get_subsystem() can refer to
already deleted subsystems.
Here is the code related to this issue.
// (1) called when deleting subsystem_mgr (in FGGlobals::~FGGlobals)
SGSubsystemGroup::~SGSubsystemGroup ()
{
for (unsigned int i = 0; i < _members.size(); i++)
{
_members[i]->printTimingStatistics();
// (Note 1): Subsystems are deleted here, but are not erased from
// SGSubsystemMgr::_subsystem_map that maps name with SGSubsystem *
delete _members[i]; // (2) this calls subsystem's destructor
}
}
// (3) called by some subsystem's destructor
SGSubsystemMgr::get_subsystem (const string &name)
{
// (Note 2) this _subsystem_map.find(name) refers already deleted subsystems
// since the maps are not erased when deleting subsystems.
map<string,SGSubsystem *>::iterator s =_subsystem_map.find(name);
if (s == _subsystem_map.end())
return 0;
else
return s->second;
}
Reading methods above tells you how dangerous it is to call get_subsystem()
from subsystem's destructor.
If you have never encountered the crash by this issue, you're simply lucky
because the deleted objects still exist when referred.
Possible solutions are:
(a) change ~FGGlobals to clearly delete the relevant subsystems prior to
deleting subsystem_mgr
(b) change SGSubsystemMgr and SGSubsystemGroup to remove deleted subsystems
from their maps and vectors.
I chose (a) for this time.
Best,
Tat
globals.diff
Description: Binary data
------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________ Flightgear-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/flightgear-devel

