Open behrisch opened 3 years ago
The call to MESegment::removeDetector is only used from the destructor of METriggeredCalibrator. Since we know that the vehicles are already destructed at this point we can simply omit the calls to MEVehicle::removeReminder (at least this is a workaround without memory leak).
Moving the call to MSCalibrator::cleanup(); ahead of delete myVehicleControl;
strangely enough does not solve the crashing (when compiled with clang on linux).
The gcc build didn't even crash before your workaround.
But sometimes calibrators are removed before the simulation ends aren't they? This would induce a crash then for the vehicle still has a dangling pointer.
No. As far as I can tell they are only deleted via the static cleanup method in the end.
Is this actually a regression ticket (Was the crash ever part of a release)? Do we need to do something else here?
Yes, the crash has been present in 1.7.0. I still think there should be a way to safely remove a METriggeredCalibrator from a running simulation without causing a memory leak, even if it is not used yet. Also the cleanup order of lanes/edges vs. segments still needs a refactoring. But none of this is high priority.
currently there is a crash in sumo\tests\sumo\extended\calibrator\swallow_downstream_jam_disabled because on deletion METriggeredCalibrator wants to remove its meandata instance from the segment which in turn wants to remove the reminder from the vehicles which are already deleted. Probably triggers should be cleaned up earlier just as detectors do in MSNet:clearAll or ~MSNet. Furthermore I don't see a reason why edges and lanes are cleared in clearAll while the meso segments are cleared in ~MSNet.