mirror of
https://github.com/apache/nuttx.git
synced 2026-05-26 10:46:28 +08:00
sim: Fix sim stack smashing problem
The reason is that the new created task receives signal while it has not entered its stack frame. Signed-off-by: chenxiaoyi <chenxiaoyi@xiaomi.com>
This commit is contained in:
@@ -32,8 +32,26 @@
|
||||
|
||||
#include <nuttx/arch.h>
|
||||
|
||||
#include "sched/sched.h"
|
||||
#include "sim_internal.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
static void pre_start(void)
|
||||
{
|
||||
struct tcb_s *tcb = this_task();
|
||||
|
||||
/* Enable signal delivery */
|
||||
|
||||
up_irq_restore(0);
|
||||
|
||||
/* Then call the real start function */
|
||||
|
||||
tcb->start();
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
@@ -93,7 +111,11 @@ void up_initial_state(struct tcb_s *tcb)
|
||||
#endif
|
||||
+ tcb->adj_stack_size;
|
||||
|
||||
tcb->xcp.regs[JB_PC] = (xcpt_reg_t)tcb->start;
|
||||
/* Mask the interrupt until switching to the new task */
|
||||
|
||||
memset(&tcb->xcp.regs[JB_FLAG], 0xff, sizeof(xcpt_reg_t) * 2);
|
||||
|
||||
tcb->xcp.regs[JB_PC] = (xcpt_reg_t)pre_start;
|
||||
|
||||
#ifdef CONFIG_SIM_ASAN
|
||||
__asan_unpoison_memory_region(tcb->stack_alloc_ptr, tcb->adj_stack_size);
|
||||
|
||||
Reference in New Issue
Block a user