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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]