NikolaiVChr / flightgear-saab-ja-37-viggen

Saab 37 Viggen for Flightgear flight simulator
http://wiki.flightgear.org/Saab_37_Viggen
GNU General Public License v2.0
27 stars 15 forks source link

`flightgear::FlightPlan::lockDelegates` assertion failed #133

Closed colingeniet closed 4 years ago

colingeniet commented 4 years ago

FG crashes with

fgfs: /var/tmp/portage/games-simulation/flightgear-9999/work/flightgear-9999/src/Navaids/FlightPlan.cxx:1750: 
void flightgear::FlightPlan::lockDelegates(): 
Assertion `!_departureChanged && !_arrivalChanged && !_waypointsChanged && !_currentWaypointChanged' failed.

steps to reproduce:

versions:

colingeniet commented 4 years ago

After more tests, the issue triggered by many other flightplan related events. The fastest/most reliable I found is to cycle runways with the L button on the TI.

colingeniet commented 4 years ago

Culprit is in Nasal/flightplan.nas, line 890: setlistener("autopilot/route-manager/current-wp", func {Polygon._wpChanged()}); It doesn't look like much, but

Result is a re-entering call of Flightplan::activate, and more specifically a re-entering call of Flightplan::unlockDelegates, which messes up the code tasked with keeping track of waypoint modifications, and triggered the assertion failure.

I think the most reasonable fix is to break the recursion with an ugly timer. Weird stuff happens when adding a timer. I don't understand the interactions of _wpChanged with the rest of flightplan.nas, in particular with activateLandingBase.

colingeniet commented 4 years ago

Fixed by https://github.com/NikolaiVChr/flightgear-saab-ja-37-viggen/commit/1180dd85500d9e59731561754a6bff3ab69425c7 for recent flightgear versions. It requires the following FG commit to work properly (FG 2020+): https://sourceforge.net/p/flightgear/flightgear/ci/45df8f51b2fdc2b2da53f778f633b9915792ebe6/

For earlier FG versions, some automation functionality are lost (e.g. automatic selection of RTB plan at the end of mission plan), but at least it does not crash (tested with 2018.3.6, current stable version).