mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-11-22 14:19:57 +08:00
_hrt_lock was a px4_sem_t and hrt_call_invoke() dropped it around the
callback so callbacks could re-enter hrt_call_*. That exposed the
callout queue to other threads mid-invocation: the entry is removed
with deadline reset to 0 (the "unqueued" sentinel), then re-inserted
unconditionally by the periodic re-arm path. Another thread re-arming
the same entry in that window (e.g. via
ScheduledWorkItem::ScheduleOnInterval()) re-inserts it too, and the
second hrt_call_enter() links the node twice, tearing the queue.
Switch _hrt_lock to a PTHREAD_MUTEX_RECURSIVE pthread_mutex and hold
it across the callout, mirroring the posix fix 9b62a1701d and matching
NuttX's enter_critical_section() nesting semantics. QURT already
relies on recursive pthread mutexes in code that runs on the DSP
today (atomic_transaction.cpp, mavlink_main.cpp).
Fixes #28922