[go: up one dir, main page]

Phi crashes FlightGear if "Other Traffic" is requested sometimes

Summary

When "Other traffic" is enabled in Phi, depending on who is around, Flightgear crashes completely with a JSON exception because of invalid UTF-8 strings. Unfortunately this makes using Phi to track nearby traffic (e.g. in flying events) impossible.

Screenshot_2025-10-17_at_10.26.17_PMScreenshot_2025-10-17_at_10.18.52_PM

I've tracked it down to the /json/ai/models\?d\=99 api call from Phi, which tries to dump the entire /ai/models subtree as a string. Luckily, I was able to find a pilot which was consistently causing the crash, and after adding the debug code this is the part that was causing the crash:

Screenshot_2025-10-17_at_10.32.19_PM

(string[7] in the above case).

I guess the crash is occurring because nlohmann json is strict by default.

The 'simple' fix is to make the dump call (https://gitlab.com/flightgear/flightgear/-/blob/next/src/Network/http/jsonprops.cxx?ref_type=heads#L193) more relaxed by changing it to something like j.dump(indent, ' ', false, nlohmann::detail::error_handler_t::replace); which results in

{
"index": 7,
"nChildren": 0,
"name": "string",
"path": "/ai/models/multiplayer/sim/multiplay/generic/string[7]",
"type": "string",
"value": "��i"
}

for the above sample.

Wanted to ask if there is a more "proper" fix, and if this simple fix can be problematic in the future.

System and version information

/sim/version/flightgear: 2024.2.0
/sim/version/simgear: 2024.2.0
/sim/version/openscenegraph: 3.6.5
/sim/version/build-date: 
/sim/version/build-type: Dev
/sim/version/revision: none
/sim/rendering/gl-info/gl-vendor: Apple
/sim/rendering/gl-info/gl-renderer: Apple M4 Max
/sim/rendering/gl-info/gl-version: 4.1 Metal - 89.4
/sim/rendering/gl-info/gl-shading-language-version: 4.10
  • SimGear: 998684d84b21bf1844a34869193045ca854e9989
  • FlightGear: e626d7f3
  • FGdata: 67d2245817a87dee1198a8095d5db77258fe9c97