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

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

commit ed368470d11b35f612c9e27503d77faa35d6521f
Author: liang.huang <[email protected]>
AuthorDate: Sat Jul 18 11:38:08 2026 +0800

    arch/risc-v: dump backtrace when killing a task with SIGSEGV
    
    When riscv_fault_handler() kills a user task with SIGSEGV, it previously
    produced no stack trace, making the crash hard to diagnose.  Call
    sched_dumpstack() on the killed task when SCHED_BACKTRACE is enabled.
    
    Assisted-by: Claude Code:claude-sonnet-5
    Signed-off-by: liang.huang <[email protected]>
---
 arch/risc-v/src/common/riscv_exception.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/arch/risc-v/src/common/riscv_exception.c 
b/arch/risc-v/src/common/riscv_exception.c
index 6f5c81b2fd8..3d45d264996 100644
--- a/arch/risc-v/src/common/riscv_exception.c
+++ b/arch/risc-v/src/common/riscv_exception.c
@@ -119,6 +119,10 @@ static void riscv_fault_handler(uintreg_t cause, void 
*regs)
       _alert("Segmentation fault in %s (PID %d: %s)\n", get_task_name(ptcb),
              tcb->pid, get_task_name(tcb));
 
+#ifdef CONFIG_SCHED_BACKTRACE
+      sched_dumpstack(tcb->pid);
+#endif
+
       tcb->flags |= TCB_FLAG_FORCED_CANCEL;
 
       /* Return to _exit function in privileged mode with argument SIGSEGV */

Reply via email to