Skip to content

Commit 52baca0

Browse files
yamtxiaoxiang781216
authored andcommitted
Increase the chance for _assert to work early in the boot
1 parent 1086a05 commit 52baca0

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

sched/misc/assert.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include <nuttx/board.h>
2929
#include <nuttx/coredump.h>
3030
#include <nuttx/fs/fs.h>
31+
#include <nuttx/init.h>
3132
#include <nuttx/irq.h>
3233
#include <nuttx/tls.h>
3334
#include <nuttx/signal.h>
@@ -569,6 +570,7 @@ static void pause_all_cpu(void)
569570
void _assert(FAR const char *filename, int linenum,
570571
FAR const char *msg, FAR void *regs)
571572
{
573+
const bool os_ready = OSINIT_OS_READY();
572574
FAR struct tcb_s *rtcb = running_task();
573575
#if CONFIG_TASK_NAME_SIZE > 0
574576
FAR struct tcb_s *ptcb = NULL;
@@ -585,14 +587,18 @@ void _assert(FAR const char *filename, int linenum,
585587
}
586588
#endif
587589

588-
flags = enter_critical_section();
590+
flags = 0; /* suppress GCC warning */
591+
if (os_ready)
592+
{
593+
flags = enter_critical_section();
594+
}
589595

590596
if (g_fatal_assert)
591597
{
592598
goto reset;
593599
}
594600

595-
if (fatal)
601+
if (os_ready && fatal)
596602
{
597603
#ifdef CONFIG_SMP
598604
pause_all_cpu();
@@ -738,5 +744,8 @@ void _assert(FAR const char *filename, int linenum,
738744
#endif
739745
}
740746

741-
leave_critical_section(flags);
747+
if (os_ready)
748+
{
749+
leave_critical_section(flags);
750+
}
742751
}

0 commit comments

Comments
 (0)