|
FhSim
3.1.0
Marine systems simulation
|
| ID | 0065 |
| Class | BUG |
| Severity | 1 |
| Status | ready |
| Models | Trawl/Vessel, Seine/Vessel, Seine/Cable |
| Found | 2026-09-25, running valgrind on Examples.EveryInputSetsUpAndTakesAStep while verifying FISH-0062 |
valgrind --leak-check=full on the headless (build/no_vis) test_fhsim_fishery --gtest_filter=Examples.* reports 1,168 bytes definitely lost in 18 blocks. ValuesDisplay is not among them (its own case is clean in both builds). The allocation sites:
src/trawl/TrawlVessel.cpp:95-96 allocate m_out_WarpPos and m_out_WarpVel (new double[m_numWarps * 3], 48 bytes each for two warps); the destructor (:98-112) frees only m_aadWarpPos and never these two. Reached through ToVessel and VesselDeploy.src/seine/CableBranchedAttractor.cpp:117-125: the destructor body is commented out, so m_cableSections (:49, :424), each InternalCableWithAttractor (:94), m_nodeConnections (:50), m_iStateCable, m_iStatePos, m_iStateVel (:406-414) and the input-port arrays from CableBranched::CreateInputports (24-byte blocks) are never freed. It includes one 6,864-byte (752 direct) record.new[] blocks allocated directly under getSimObject with no symbol (???, likely inlined constructors); not attributed yet.A few kilobytes lost per model load. Harmless for a single run, but a host that builds many models in one process (the test binary, an FMU re-instantiated by its host) grows. No numeric effect.
Free the arrays in the destructors, or replace them with std::vector, as FISH-0016 did for Crowfoot, TrawlDoorAddedFoil and ValuesDisplay. Restore the CableBranchedAttractor destructor after checking why it was commented out (possible double free with the base CableBranched). Attribute the seven 8-byte blocks with a debug build.
The valgrind run above reports no definitely-lost block from libfhsim_fishery.so; every regression baseline stays byte-identical.
Low for TrawlVessel. Moderate for CableBranchedAttractor: the commented-out destructor may hide an ownership conflict with CableBranched, so a naive restore could double free.