Clock::attachAlarm stores a raw Alarm* in an internal vector, but there is no detachAlarm/removeAlarm counterpart anywhere in TimeMgr. Several classes (IOStream, TimeStepper, SfcCoupling) attach Alarm members to a shared Clock and later destroy themselves via erase()/clear() without detaching their alarms first. If the Clock outlives the destroyed object and advance()/setCurrentTime() is called, it dereferences a dangling Alarm* (use-after-free).
This issue came up when I had copilot review #458 locally. It's a bit out of my wheelhouse C++ wise, so very open to push back here.
Clock::attachAlarmstores a rawAlarm*in an internal vector, but there is nodetachAlarm/removeAlarmcounterpart anywhere inTimeMgr. Several classes (IOStream,TimeStepper,SfcCoupling) attachAlarmmembers to a sharedClockand later destroy themselves viaerase()/clear()without detaching their alarms first. If theClockoutlives the destroyed object andadvance()/setCurrentTime()is called, it dereferences a danglingAlarm*(use-after-free).This issue came up when I had copilot review #458 locally. It's a bit out of my wheelhouse C++ wise, so very open to push back here.