Skip to content

Commit

Permalink
os/kernel/task, os/arch/arm/src/common: Fix stack overflow issue when…
Browse files Browse the repository at this point in the history
… printing TCB list in assert logs

when printing the assert information, the size of stack used for each
TCB is printed wrong and showing stack overflow. This is because when
we are checking the TCB stack, we check from stack_alloc_ptr instead of
stack_base_ptr. So, stack_alloc_ptr points to TLS Data, Arguments and
then available stack whereas stack_base_ptr directly points to available
stack.

Signed-off-by: Neelkumar Patel <neel.patel@samsung.com>
  • Loading branch information
neel-samsung authored and kishore-sn committed Apr 2, 2024
1 parent b0f35d1 commit 8d3f6d2
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion os/arch/arm/src/common/up_checkstack.c
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ static size_t do_stackcheck(uintptr_t start, uintptr_t end)

size_t up_check_tcbstack(FAR struct tcb_s *tcb)
{
return do_stackcheck((uintptr_t)tcb->stack_alloc_ptr, (uintptr_t)tcb->adj_stack_ptr);
return do_stackcheck((uintptr_t)tcb->stack_base_ptr, (uintptr_t)tcb->adj_stack_ptr);
}

ssize_t up_check_tcbstack_remain(FAR struct tcb_s *tcb)
Expand Down
2 changes: 1 addition & 1 deletion os/kernel/task/task_dumptasks.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ static void task_taskdump(FAR struct tcb_s *tcb, FAR void *arg)
lldbg_noarg(TASKDUMP_FORMAT, TASKDUMP_VALUE);

#ifdef CONFIG_STACK_COLORATION
if (used_stack_size == tcb->adj_stack_size) {
if (used_stack_size >= tcb->adj_stack_size) {
lldbg_noarg(" !!! PID (%d) STACK OVERFLOW !!! \n", tcb->pid);
}
#endif
Expand Down

0 comments on commit 8d3f6d2

Please sign in to comment.