Concrete type of vehicle missing in E3 collector
I am using a Multi-Entry-Exit Detector (E3) to collect some traffic statistics in my network. At some point the simulation crashes with the following message:
pure virtual method called terminate called without an active exception
Using gdb's stack, I found out that the error happens in MSE3Collector::detectorUpdate when accessing the speed of a vehicle: myCurrentMeanSpeed += veh->getSpeed();
After some debugging, it seems that the vehicle stored in the internal data structure of the detector (i.e., myEnteredContainer) is missing its concrete type which should be MSVehicle. Therefore, the pure virtual method from the base class SUMOVehicle is used which produces the error.
I suspect that the issue originates from call of MSE3Collector::MSE3EntryReminder::notifyMove in MSVehicle::workOnMoveReminders:
if (!rem->first->notifyMove(*this, oldPos + rem->second, newPos + rem->second, MAX2(0., newSpeed))) {
where the concrete type of the vehicle (i.e., this) might get lost due to slicing.
This behavior, however, only happens after some simulation time and also not to all vehicles. At time of occurrence, there were two entries in the data structure (myEnteredContainer), the latter of which still had its concrete type of MSVehicle.
I am using a version of plexe-sumo, however, the aforementioned parts of the code seem to be the similar to the current sumo master.
Here is the stack trace of gdb:
#0 0x00007ffff623f428 in __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:54 #1 0x00007ffff624102a in __GI_abort () at abort.c:89 #2 0x00007ffff6b8284d in __gnu_cxx::__verbose_terminate_handler() () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6 #3 0x00007ffff6b806b6 in ?? () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6 #4 0x00007ffff6b80701 in std::terminate() () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6 #5 0x00007ffff6b8123f in __cxa_pure_virtual () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6 #6 0x0000000000cca178 in MSE3Collector::detectorUpdate (this=0x13cb070, step=1779300) at julian.heinovski/src/repos/sumo-plexe/src/microsim/output/MSE3Collector.cpp:365 #7 0x0000000000cada49 in MSDetectorControl::updateDetectors (this=0x13b6ac0, step=1779300) at julian.heinovski/src/repos/sumo-plexe/src/microsim/output/MSDetectorControl.cpp:120 #8 0x0000000000af1f57 in MSNet::writeOutput (this=0x13b6cb0) at julian.heinovski/src/repos/sumo-plexe/src/microsim/MSNet.cpp:631 #9 0x0000000000af18e5 in MSNet::simulationStep (this=0x13b6cb0) at julian.heinovski/src/repos/sumo-plexe/src/microsim/MSNet.cpp:539 #10 0x0000000000af00da in MSNet::simulate (this=0x13b6cb0, start=0, stop=7200000) at julian.heinovski/src/repos/sumo-plexe/src/microsim/MSNet.cpp:331 #11 0x0000000000a22cc6 in main (argc=13, argv=0x7fffffffd678) at julian.heinovski/src/repos/sumo-plexe/src/sumo_main.cpp:72
most likely this happens because a vehicle is removed from the simulation while being tracked by the detector. Once the vehicle has been partly destructed the 'pure virtual' exception is a common failure case.
It would be best if you could reproduce this crash without plexe. As this may be difficult you could add the options --movereminder-output logfile --movereminder-output.vehicles id1,id2,id3,...
where id1,id2 etc are the ids of all vehicles in the simulation Note, that this option is only available in the debug version of sumo. If you attach the resulting logfile I can probably figure out the bug.