|
FhSim
3.1.0
Marine systems simulation
|
| ID | 0075 |
| Class | API |
| Severity | 2 |
| Status | ready |
Models: —
Found: 2026-10-22, porting fhsim_maritime to fhsim 3 (its OIS input SimObjects look up the visualization in RenderInit)
include/fhsim/NFhSim.h:143 documents kSimMgrKeyFhVisualization as "the FhVisualization instance". Two observers register different, unrelated types under it with the untyped SetPtr:
src/visual/observer/VisualizationObserver.cpp:33: simMgr->SetPtr(fhsim::kSimMgrKeyFhVisualization, &m_visualization); with an FhVisualization (FhVis).src/visual/observer/VisualizationSDLObserver.cpp:35: the same call with an FhVisualizationSDL (FhSimUI).src/visual/dll/module/VisDllEntry.cpp:98 registers a third pointer under it.
A SimObject that casts the pointer to FhVisualization* (as fhsim_maritime's gamepad and console input objects must, to reach the input manager) is undefined behaviour under FhSimUI. fhsim_maritime works under FhVis only.
Register the visualization with SetTypedSharedResource (or under two keys, one per type), so that a typed lookup of the wrong type returns null; document which hosts provide which type.
A SimObject test that runs under each host and does the typed lookup: it gets the instance under FhVis and null, not a wrong pointer, under FhSimUI.
A crash or silent memory corruption in plugins that use the key under FhSimUI.