This is an automated email from the ASF dual-hosted git repository.

xiaoxiang781216 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit 0851e281240598d3df623124124756b3aca084f6
Author: yinshengkai <[email protected]>
AuthorDate: Wed Jun 25 20:02:46 2025 +0800

    sched/backtrace: compare the tid with running_task()
    
    sched_backtrace() unwinds the calling context when tid is the pid of
    this_task(), but up_backtrace() of every architecture treats only
    running_task() as the current task.  In interrupt context during a
    context switch, this_task() is already the task that runs next, so the
    two disagree and the wrong context is unwound.
    
    Use running_task(), as up_backtrace() does.
    
    Signed-off-by: yinshengkai <[email protected]>
---
 sched/sched/sched_backtrace.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sched/sched/sched_backtrace.c b/sched/sched/sched_backtrace.c
index b16e29bf7ee..284a32fce52 100644
--- a/sched/sched/sched_backtrace.c
+++ b/sched/sched/sched_backtrace.c
@@ -123,7 +123,7 @@ static int sched_backtrace_handler(FAR void *cookie)
 
 int sched_backtrace(pid_t tid, FAR void **buffer, int size, int skip)
 {
-  FAR struct tcb_s *tcb = this_task();
+  FAR struct tcb_s *tcb = running_task();
   int ret = 0;
 
   if (size <= 0 || buffer == NULL)

Reply via email to