Recently I noticed that some search attempts with nasal function navinfo()
(and also findNavaidsByID()
and possibly some else under certain conditions) were crashing the 2020.4 without any remarks in log, even at bulk level, while 2020.3.19 did absolutely fine.
The file with nasal console code to reproduce the issue is attached, start position should not matter but tested in UERR and LOWI airports.
So far I managed to spot the issue only with ILS search, but I'm not familiar with FG codebase, so I can't guarantee that there no other cases causing navinfo()
, airportinfo()
, findNavaidByID()
or other functions working with navaid or airport ghosts to crash the 2020.4.
I tested it myself on Windows 10 and, unfortunately, I don't have GDB to debug this properly, but I will also attach a MacOS crash reporter backtrace (which is possibly similar to GDB output).
It's something to do with a custom scenery path, try with only the base scenery configured?
Tried right now and without any custom scenery the issue is still present on 2020.4
Should've clarify this better: macos crash report was provided not by me but by Fahim on FG discord server, so it's possible that there are also some issues with his FG config.
But that's the best what I have.
Last edit: Ivan Strebkov 2024-01-18
I can replicate the issue by just calling this:
This is without custom scenery. Just TerraSync.
@frougon, I wonder if this may have something to do with your commit [351ca1]? For some reason the sceneryPath seems to be gibberish (I once got
Path "▼
instead ofPath ""
when printing it).But, interestingly it doesn't always crash with "SG". Sometimes it doesn't. Sometimes it crashes with "SB" or "SA", sometimes it doesn't.
The whole findNavaidsByID function seems a bit fishy though, as the results of findNavaidsByID() seem to consistently include duplicates (but only for some of the items!) on the first call in a FlightGear session...
For example, first call of
findNavaidsByID("SA");
Second and consecutive calls of
findNavaidsByID("SA");
@jmturner or @frougon: any ideas on how to further debug this?
Related
Commit: [351ca1]
I'm going to debug it 'soon', don't worry about it (got some other changes in the same area I need to finish, first)
Thanks @gijsrooy for the nice recipe to reproduce the bug.
AFAICS, this is not related to my commit 351ca111.
While debugging this crash using what Gijs proposed, I found that
NavDataCachePrivate::findAllByString()
was running the following query:However, the result was consistently 325005 which does not correspond to
ident="LFLS"
:This happens because
NavDataCachePrivate::findAllByString()
is used as if it were reentrant, whereas it is not.The actual query is:
SELECT rowid FROM positioned WHERE ident=?1 AND type>=?2 AND type <=?3
which is cached in thefindByStringDict
std::map. Using Gijs' recipe, this query is executed with"SG"
substituted for?1
and before thereset()
is done for the prepared SQL statement, the same query using the same prepared SQL statement is executed with"LFLS"
substituted for?1
(this is because of the reentrant call originating fromNavDataCache::loadById()
inNavDataCachePrivate::findAllByString()
). However, sincereset()
hasn't been called yet for the first query,stepSelect()
returns results forident="SG"
(actually, there is even another query in between, forident="ENSG"
).Anyway, as
NavDataCachePrivate::findAllByString()
is written, it needs to be reentrant which, unless I'm mistaken, makes it impossible to cache the prepared SQL statements as attempted withfindByStringDict
(these statements retain execution state untilreset()
is called for them).The attached patch removes this caching and appears to fix the crash triggered by Gijs' recipe.
(This might also fix what @merspieler reported on flightgear-devel about some airports not being found in their custom WS3 scenery using updated WS3 apt.dat.)
I'd prefer to avoid the re-entrancy rather than pessimise the performance, though: the reentrancy was not really intended here, just na effect of the 'loadILSData' call.
From a bit more reading: I think we can just change findAllByString to build up a vector<positionedid>, reset the query and then call loadById on each, which will avoid the re-entrancy.</positionedid>
@jmturner No more time today but I believe you are quite right. Besides, I retract that the problem would not be related to my commit 351ca111—it did introduce reentrancy because of:
Anyway, to bed now. :)
Regards
New patch attached. Lightly tested but seems to work for “Gijs' crash recipe.” :-)
Tried both patches, the problem persists.
Thanks for mentioning us tho
@merspieler To be clear, you are not talking about the problem mentioned in this report, right? If this is indeed a different issue, please give a foolproof recipe to reproduce it (would be better in a separate report). I may be able to debug it, though I can't promise this will happen in a short time frame.
Last edit: Florent Rougon 2024-01-25
Yes, it's about the issue from the mailing list you've mentioned.
I'll open a new ticket.
Hi Florent, fix_findAllByString_v2.patch works fine here! No more duplicate entries on the first call, and no crashes so far. Great job!
Yep that path looks reaosnable to me as well, Florent or Gojs you can apply, I am making some other NavCache changes right now so don't want to switch branches
@jmturner Thanks for your confirmation! I've pushed the fix with minor editing changes [fbbc14] :
id
(resp.ids
) replaced withguid
(resp.guids
) for consistency with other NavDataCache code.Regards
Related
Commit: [fbbc14]
Last edit: Gijs 2024-01-25