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

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

commit 41e136195399e89f910e83f8f1fd7e804ac707a0
Author: zhangyu117 <[email protected]>
AuthorDate: Mon Mar 10 17:08:00 2025 +0800

    arch/tricore: dealing with csa leak issue under task_restart
    
    task_restart() calls up_initial_state() again on an existing tcb, which
    allocates a new CSA chain without releasing the old one, so every
    restart leaks CSAs. Reclaim the existing CSA chain first if present.
    
    Signed-off-by: zhangyu117 <[email protected]>
---
 arch/tricore/src/common/tricore_initialstate.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/arch/tricore/src/common/tricore_initialstate.c 
b/arch/tricore/src/common/tricore_initialstate.c
index fcd0bb8c079..3c0baf997f2 100644
--- a/arch/tricore/src/common/tricore_initialstate.c
+++ b/arch/tricore/src/common/tricore_initialstate.c
@@ -57,6 +57,15 @@
 void up_initial_state(struct tcb_s *tcb)
 {
   struct xcptcontext *xcp = &tcb->xcp;
+  uintptr_t pcxi;
+
+  /* Reclaim possible CSA links */
+
+  pcxi = tricore_addr2csa(xcp->regs);
+  if (pcxi & FCX_FREE)
+    {
+      tricore_reclaim_csa(pcxi);
+    }
 
   /* Initialize the initial exception register context structure */
 

Reply via email to