You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by "yushuailong (via GitHub)" <gi...@apache.org> on 2026/10/02 09:26:47 UTC

[PR] sched/group: Fix task group lifecycle cleanup [nuttx]

yushuailong opened a new pull request, #20435:
URL: https://github.com/apache/nuttx/pull/20435

   
   ## Summary
    
   This PR fixes two task-group lifecycle issues:
   
     - `group_kill_children()` sets `GROUP_FLAG_EXITING`, but `task_restart()` reuses the existing task group. Clear the flag after the old child threads have been removed so that the restarted group returns to its normal state.
   
     - Kernel threads share the statically allocated `g_kthread_group`. If initialization of the first kernel thread group fails, avoid passing this static object to `kmm_free()` and detach it from the failed TCB.
   
     Without these fixes, a restarted task may retain a stale exiting state, causing later child cleanup to be skipped and changing cancellation behavior. A kernel-group initialization failure may also attempt to free static storage and corrupt the kernel heap.
   
   ## Impact
   
    - Restores normal task-group and cancellation behavior after `task_restart()`.
     - Ensures subsequent task shutdowns can still terminate child threads.
     - Prevents an invalid free and possible kernel heap corruption on the kernel-thread group initialization error path.
     - No public API, ABI, or configuration changes.
   
   ## Testing
   
   Build host: macOS 26.6.2 ARM64, Apple Clang 21.0.0.
   Target: sim:ostest.
   Build: make completes successfully with LD: nuttx.
   Static checks: nxstyle, checkpatch pass.
   Runtime smoke test: ./nuttx starts and proceeds through enabled OSTest cases without an assertion in the observed run.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] sched/group: Fix task group lifecycle cleanup [nuttx]

Posted by "xiaoxiang781216 (via GitHub)" <gi...@apache.org>.
xiaoxiang781216 merged PR #20435:
URL: https://github.com/apache/nuttx/pull/20435


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] sched/group: Fix task group lifecycle cleanup [nuttx]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #20435:
URL: https://github.com/apache/nuttx/pull/20435#issuecomment-5949499234

   <!-- membrowse-pr-comment -->
   ## <img src="https://membrowse.com/membrowse-logo.svg" height="24" align="top"> MemBrowse Memory Report
   
   ### [arduino-mega2560](https://membrowse.com/public/apache/nuttx/target/arduino-mega2560/compare?head=67a89ea43b021210f4ddeba52b4cb97c1132dded&base=c046c337c179b55d0e400d7018e35f0528f65b0e)
     - **flash**: .text +62 B (+0.1%, 65,396 B / 262,144 B, total: 25% used)
   ### [esp32-devkitc](https://membrowse.com/public/apache/nuttx/target/esp32-devkitc/compare?head=67a89ea43b021210f4ddeba52b4cb97c1132dded&base=c046c337c179b55d0e400d7018e35f0528f65b0e)
     - **ROM**: .flash.text +16 B (+0.0%, 124,980 B / 4,194,272 B, total: 3% used)
     - **irom0_0_seg**: .flash.text +16 B (+0.0%, 89,184 B / 3,342,304 B, total: 3% used)
   ### [mirtoo](https://membrowse.com/public/apache/nuttx/target/mirtoo/compare?head=67a89ea43b021210f4ddeba52b4cb97c1132dded&base=c046c337c179b55d0e400d7018e35f0528f65b0e)
     - **kseg0_progmem**: .text +56 B (+0.1%, 67,940 B / 131,072 B, total: 52% used)
   ### [qemu-armv8a](https://membrowse.com/public/apache/nuttx/target/qemu-armv8a/compare?head=67a89ea43b021210f4ddeba52b4cb97c1132dded&base=c046c337c179b55d0e400d7018e35f0528f65b0e)
     - **Code**: .text.group_allocate +32 B, .text.task_restart +16 B (+0.0%, 346,944 B)
   ### [qemu-intel64](https://membrowse.com/public/apache/nuttx/target/qemu-intel64/compare?head=67a89ea43b021210f4ddeba52b4cb97c1132dded&base=c046c337c179b55d0e400d7018e35f0528f65b0e)
     - **Code**: .text +40 B (+0.0%, 8,661,979 B)
   ### [rx65n-rsk2mb](https://membrowse.com/public/apache/nuttx/target/rx65n-rsk2mb/compare?head=67a89ea43b021210f4ddeba52b4cb97c1132dded&base=c046c337c179b55d0e400d7018e35f0528f65b0e)
     - **ROM**: .text +16 B (+0.0%, 86,896 B / 2,097,152 B, total: 4% used)
   ### [s698pm-dkit](https://membrowse.com/public/apache/nuttx/target/s698pm-dkit/compare?head=67a89ea43b021210f4ddeba52b4cb97c1132dded&base=c046c337c179b55d0e400d7018e35f0528f65b0e)
     - **Code**: .text +32 B (+0.0%, 368,960 B)
   ### [stm32-nucleo-f103rb](https://membrowse.com/public/apache/nuttx/target/stm32-nucleo-f103rb/compare?head=67a89ea43b021210f4ddeba52b4cb97c1132dded&base=c046c337c179b55d0e400d7018e35f0528f65b0e)
     - **flash**: .text +12 B (+0.0%, 34,640 B / 131,072 B, total: 26% used)
   *No memory changes detected for:*
   - [hifive1-revb](https://membrowse.com/public/apache/nuttx/target/hifive1-revb/compare?head=67a89ea43b021210f4ddeba52b4cb97c1132dded&base=c046c337c179b55d0e400d7018e35f0528f65b0e)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] sched/group: Fix task group lifecycle cleanup [nuttx]

Posted by "acassis (via GitHub)" <gi...@apache.org>.
acassis commented on code in PR #20435:
URL: https://github.com/apache/nuttx/pull/20435#discussion_r4165780969


##########
sched/group/group_create.c:
##########
@@ -287,7 +287,12 @@ int group_allocate(FAR struct tcb_s *tcb, uint8_t ttype)
     }
 #endif
 
-  kmm_free(group);
+  if (group != &g_kthread_group)

Review Comment:
   Please include a comment here. Why the group cannot be from a kthread? Is it when a task depends on a kthread and this code could remove the kthread instead?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org