mirror of
https://github.com/apache/nuttx.git
synced 2026-09-24 00:42:03 +08:00
assert: fix DEBUGASSERT recursive triggering
Add head pointer checks in notifier_call_chain macros to prevent recursion into sched_lock() when assertions are triggered during early system startup. This avoids cascading DEBUGASSERT failures when the notifier head is empty or uninitialized. backtrace: DEBUGASSERT(rtcb && rtcb->lockcount < MAX_LOCK_COUNT); sched_lock() panic_notifier_call_chain _assert() arm64_fatal_handler Signed-off-by: hujun5 <hujun5@xiaomi.com>
This commit is contained in:
@@ -212,10 +212,12 @@ extern "C"
|
||||
do \
|
||||
{ \
|
||||
FAR struct atomic_notifier_head *nh = (nhead); \
|
||||
irqstate_t flags; \
|
||||
flags = rspin_lock_irqsave_nopreempt(&nh->lock); \
|
||||
notifier_call_chain(nh->head, (val), (v), -1, NULL); \
|
||||
rspin_unlock_irqrestore_nopreempt(&nh->lock, flags); \
|
||||
if (nh != NULL && nh->head != NULL) \
|
||||
{ \
|
||||
irqstate_t flags = rspin_lock_irqsave_nopreempt(&nh->lock); \
|
||||
notifier_call_chain(nh->head, (val), (v), -1, NULL); \
|
||||
rspin_unlock_irqrestore_nopreempt(&nh->lock, flags); \
|
||||
} \
|
||||
} \
|
||||
while(0)
|
||||
|
||||
@@ -262,12 +264,15 @@ extern "C"
|
||||
do \
|
||||
{ \
|
||||
FAR struct blocking_notifier_head *nh = (nhead); \
|
||||
if (nxmutex_lock(&nh->mutex) < 0) \
|
||||
if (nh != NULL && nh->head != NULL) \
|
||||
{ \
|
||||
break; \
|
||||
if (nxmutex_lock(&nh->mutex) < 0) \
|
||||
{ \
|
||||
break; \
|
||||
} \
|
||||
notifier_call_chain(nh->head, (val), (v), -1, NULL); \
|
||||
nxmutex_unlock(&nh->mutex);\
|
||||
} \
|
||||
notifier_call_chain(nh->head, (val), (v), -1, NULL); \
|
||||
nxmutex_unlock(&nh->mutex);\
|
||||
} \
|
||||
while(0)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user