From 0ea6a82b3dc3300dca62d650f1ab7357a0ea4643 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Cab=C3=A9?= Date: Tue, 13 Oct 2026 03:08:42 +0000 Subject: [PATCH] fix(tone_alarm): cancel the end of the note when the driver stops MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The driver ends each note with an HRT callout on its _hrt_call member. When the driver stopped while a note was playing, the callout stayed queued after the object was deleted, and the HRT then read the freed hrt_call at the end of the note and called InterruptStopNote() from it, or crashed if the memory had been reused. Assisted-by: Claude:opus-5.5 Signed-off-by: Benjamin Cabé --- src/drivers/tone_alarm/ToneAlarm.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/drivers/tone_alarm/ToneAlarm.cpp b/src/drivers/tone_alarm/ToneAlarm.cpp index 77e4af3b05b..554fd5ef50c 100644 --- a/src/drivers/tone_alarm/ToneAlarm.cpp +++ b/src/drivers/tone_alarm/ToneAlarm.cpp @@ -51,6 +51,8 @@ ToneAlarm::ToneAlarm() : ToneAlarm::~ToneAlarm() { + // the end of the note would otherwise be called on the deleted driver + hrt_cancel(&_hrt_call); ToneAlarmInterface::stop_note(); }