Skip to content

TimeMgr::Clock has no way to detach an Alarm, risking dangling pointers #459

Description

@andrewdnolan

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.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions