assert: Avoid recursive calls of Assert
After the structure of the kernel core is wrong, dump_stack, dumpstack is easy to appear crash Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
This commit is contained in:
parent
75f81e6e24
commit
b3794c8af7
@ -104,6 +104,8 @@ static FAR const char * const g_ttypenames[4] =
|
||||
"Invalid"
|
||||
};
|
||||
|
||||
static bool g_fatal_assert = false;
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
@ -549,6 +551,11 @@ void _assert(FAR const char *filename, int linenum,
|
||||
|
||||
flags = enter_critical_section();
|
||||
|
||||
if (g_fatal_assert)
|
||||
{
|
||||
goto reset;
|
||||
}
|
||||
|
||||
/* try to save current context if regs is null */
|
||||
|
||||
if (regs == NULL)
|
||||
@ -567,7 +574,11 @@ void _assert(FAR const char *filename, int linenum,
|
||||
{
|
||||
fatal = false;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
g_fatal_assert = true;
|
||||
}
|
||||
|
||||
notifier_data.rtcb = rtcb;
|
||||
notifier_data.regs = regs;
|
||||
@ -666,6 +677,7 @@ void _assert(FAR const char *filename, int linenum,
|
||||
|
||||
reboot_notifier_call_chain(SYS_HALT, NULL);
|
||||
|
||||
reset:
|
||||
#if CONFIG_BOARD_RESET_ON_ASSERT >= 1
|
||||
board_reset(CONFIG_BOARD_ASSERT_RESET_VALUE);
|
||||
#else
|
||||
|
Loading…
Reference in New Issue
Block a user