FhSim  3.1.0
Marine systems simulation
Loading...
Searching...
No Matches
0141 — PorousDiscWakeSource stores the ISimObjectCreator pointer past FinalSetup
ID 0141
Class BUG
Severity 1
Status ready

Models: PorousDiscWakeSource

Found: 2026-10-28, while wiring the aggregation-field warning (feature aggregation-field)

Evidence

src/environment/PorousDiscWakeSource.cpp:123 stores the creator: m_logger = Creator;, and src/environment/PorousDiscWakeSource.cpp:162 uses it at the first time step: m_logger->LogInfo(message.str());. fhsim include/fhsim/simobject/ISimObjectCreator.h:34-38: "The pointer a SimObject receives is valid only during the call it is passed to (...): do not store it. It is one cursor of the engine that is moved from SimObject to SimObject".

Effect

The message about a changed seabed-image depth is attributed to whatever SimObject the cursor speaks for at that time, or reaches a cursor that is no longer valid.

Possible fix

Store the host's logger instead, as Environment does for the aggregation fields: in FinalSetup, Creator->GetSharedResource<PrintDuringExec>(fhsim::kSimMgrKeyPrinter, fhsim::LogLevel_Debug) (null under headless and mock hosts), then WriteLog(GetName() + ": ...", fhsim::LogLevel_Info).

Test that would prove it

A test whose host returns a recording PrintDuringExec, with the bathymetry set after FinalSetup: the message is written once, with this object's name.

Risk

Low; log text only.