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

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


The following commit(s) were added to refs/heads/releases/12.6 by this push:
     new 14da04e988 sched/tcb: fix 12320 regression
14da04e988 is described below

commit 14da04e988cd5335f50888d5c5f9ba5a643cb815
Author: Yanfeng Liu <[email protected]>
AuthorDate: Tue Jun 25 16:36:13 2024 +0800

    sched/tcb: fix 12320 regression
    
    This patch attempts to fix regressions reported for pull# 12320.
    
    Signed-off-by: Yanfeng Liu <[email protected]>
---
 sched/init/nx_bringup.c        | 6 ++++--
 sched/sched/sched_releasetcb.c | 4 ++--
 sched/task/exit.c              | 6 +++++-
 3 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/sched/init/nx_bringup.c b/sched/init/nx_bringup.c
index c1944a45be..152dcc8ab2 100644
--- a/sched/init/nx_bringup.c
+++ b/sched/init/nx_bringup.c
@@ -529,9 +529,11 @@ int nx_bringup(void)
 
 #if !defined(CONFIG_DISABLE_ENVIRON) && (defined(CONFIG_PATH_INITIAL) || \
      defined(CONFIG_LDPATH_INITIAL))
-  /* We an save a few bytes by discarding the IDLE thread's environment. */
+  /* We would save a few bytes by discarding the IDLE thread's environment.
+   * But when kthreads share the same group, this is no longer proper, so
+   * we can't do clearenv() now.
+   */
 
-  clearenv();
 #endif
 
   sched_trace_end();
diff --git a/sched/sched/sched_releasetcb.c b/sched/sched/sched_releasetcb.c
index 9c74bf1154..594da261e7 100644
--- a/sched/sched/sched_releasetcb.c
+++ b/sched/sched/sched_releasetcb.c
@@ -170,9 +170,9 @@ int nxsched_release_tcb(FAR struct tcb_s *tcb, uint8_t 
ttype)
 
       nxtask_joindestroy(tcb);
 
-      /* Kernel thread and group still reference by pthread */
+      /* Task still referenced by pthread */
 
-      if (ttype != TCB_FLAG_TTYPE_PTHREAD)
+      if (ttype == TCB_FLAG_TTYPE_TASK)
         {
           ttcb = (FAR struct task_tcb_s *)tcb;
           if (!sq_empty(&ttcb->group.tg_members)
diff --git a/sched/task/exit.c b/sched/task/exit.c
index 794bc6e2b4..5971aa9069 100644
--- a/sched/task/exit.c
+++ b/sched/task/exit.c
@@ -64,7 +64,11 @@ void _exit(int status)
    * exit through a different mechanism.
    */
 
-  group_kill_children(tcb);
+  if ((tcb->flags & TCB_FLAG_TTYPE_MASK) != TCB_FLAG_TTYPE_KERNEL)
+    {
+      group_kill_children(tcb);
+    }
+
 #endif
 
   /* Perform common task termination logic.  This will get called again later

Reply via email to