mirror of
https://github.com/apache/nuttx.git
synced 2026-08-01 20:28:58 +00: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:
parent
2bfff207fd
commit
fd67ef3af9
1 changed files with 13 additions and 8 deletions
|
|
@ -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)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue