This is an automated email from the ASF dual-hosted git repository.
xiaoxiang781216 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new dc4c846d329 sched/environ: Serialize clearenv updates.
dc4c846d329 is described below
commit dc4c846d329ba0d9d7bb1bb8aa13f959654ed31a
Author: yushuailong <[email protected]>
AuthorDate: Tue Sep 8 20:16:43 2026 +0800
sched/environ: Serialize clearenv updates.
Protect the environment release in clearenv() with the task group mutex.
This prevents concurrent environment operations from racing with cleanup.
Assisted-by: OpenAI Codex
Signed-off-by: yushuailong <[email protected]>
---
sched/environ/env_clearenv.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/sched/environ/env_clearenv.c b/sched/environ/env_clearenv.c
index baed11bd223..df04888ce1b 100644
--- a/sched/environ/env_clearenv.c
+++ b/sched/environ/env_clearenv.c
@@ -60,9 +60,13 @@
int clearenv(void)
{
FAR struct tcb_s *tcb = this_task();
- DEBUGASSERT(tcb->group);
+ FAR struct task_group_s *group = tcb->group;
- env_release(tcb->group);
+ DEBUGASSERT(group);
+
+ nxrmutex_lock(&group->tg_mutex);
+ env_release(group);
+ nxrmutex_unlock(&group->tg_mutex);
return OK;
}