4
0
mirror of https://github.com/RT-Thread/rt-thread.git synced 2025-02-21 02:27:10 +08:00

fix some bug when stack grows upward

This commit is contained in:
zhaohengbo 2018-12-15 11:20:24 +08:00
parent 61b8db8ee9
commit afcd8b4521
2 changed files with 8 additions and 1 deletions

View File

@ -116,7 +116,7 @@ static long _list_thread(struct rt_list_node *list)
else if (stat == RT_THREAD_CLOSE) rt_kprintf(" close ");
#if defined(ARCH_CPU_STACK_GROWS_UPWARD)
ptr = (rt_uint8_t *)thread->stack_addr + thread->stack_size;
ptr = (rt_uint8_t *)thread->stack_addr + thread->stack_size - 1;
while (*ptr == '#')ptr --;
rt_kprintf(" 0x%08x 0x%08x %02d%% 0x%08x %03d\n",

View File

@ -82,10 +82,17 @@ static void _rt_scheduler_stack_check(struct rt_thread *thread)
{
RT_ASSERT(thread != RT_NULL);
#if defined(ARCH_CPU_STACK_GROWS_UPWARD)
if (*((rt_uint8_t *)((rt_ubase_t)thread->stack_addr + thread->stack_size - 1)) != '#' ||
(rt_ubase_t)thread->sp <= (rt_ubase_t)thread->stack_addr ||
(rt_ubase_t)thread->sp >
(rt_ubase_t)thread->stack_addr + (rt_ubase_t)thread->stack_size)
#else
if (*((rt_uint8_t *)thread->stack_addr) != '#' ||
(rt_ubase_t)thread->sp <= (rt_ubase_t)thread->stack_addr ||
(rt_ubase_t)thread->sp >
(rt_ubase_t)thread->stack_addr + (rt_ubase_t)thread->stack_size)
#endif
{
rt_ubase_t level;