You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2026/09/10 19:00:22 UTC

(nuttx) branch master updated (d6456092542 -> 23a724dc0f8)

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

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


    from d6456092542 tools/nxstyle: whitelist Micro XRCE-DDS type names
     new 91b4b0a91e5 sched: fix parent process check using wrong pid field
     new 7260437f7d6 sched/sched: fix NULL param dereference in sched_setscheduler
     new 1a7a1891364 sched/cpuload: fix hardcoded 100000 should be USEC_PER_SEC
     new 23a724dc0f8 sched/waitid: honor WNOWAIT instead of discarding child status

The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 sched/sched/sched_cpuload_oneshot.c |  2 +-
 sched/sched/sched_setscheduler.c    |  5 +++++
 sched/sched/sched_waitid.c          | 28 +++++++++++++++++-----------
 sched/sched/sched_waitpid.c         |  3 ++-
 4 files changed, 25 insertions(+), 13 deletions(-)


(nuttx) 04/04: sched/waitid: honor WNOWAIT instead of discarding child status

Posted by xi...@apache.org.
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

commit 23a724dc0f8aea1531bfeb7a900b7019443a21d6
Author: yushuailong <yy...@qq.com>
AuthorDate: Thu Sep 10 17:03:23 2026 +0800

    sched/waitid: honor WNOWAIT instead of discarding child status
    
    waitid() documents WNOWAIT support but exited_child() unconditionally
    removed and freed the child status entry, so a second wait on the same
    child failed with ECHILD. Debug builds were also inconsistent: the
    options mask rejected WNOWAIT entirely with ENOSYS.
    
    Pass options down to exited_child() and skip the discard when WNOWAIT
    is set, matching waitpid(), and add WNOWAIT to the debug options mask.
    
    Assisted-by: OpenAI Codex
    Signed-off-by: yushuailong <yy...@qq.com>
---
 sched/sched/sched_waitid.c | 23 ++++++++++++++---------
 1 file changed, 14 insertions(+), 9 deletions(-)

diff --git a/sched/sched/sched_waitid.c b/sched/sched/sched_waitid.c
index 330f26afec6..ca7525cd778 100644
--- a/sched/sched/sched_waitid.c
+++ b/sched/sched/sched_waitid.c
@@ -56,7 +56,7 @@
 #ifdef CONFIG_SCHED_CHILD_STATUS
 static void exited_child(FAR struct tcb_s *rtcb,
                          FAR struct child_status_s *child,
-                         FAR siginfo_t *info)
+                         FAR siginfo_t *info, int options)
 {
   /* The child has exited. Return the saved exit status (and some fudged
    * information).
@@ -72,10 +72,15 @@ static void exited_child(FAR struct tcb_s *rtcb,
       info->si_status          = child->ch_status;
     }
 
-  /* Discard the child entry */
+  /* Discard the child entry unless WNOWAIT is set (the caller wants the
+   * child to remain in a waitable state).
+   */
 
-  group_remove_child(rtcb->group, child->ch_pid);
-  group_free_child(child);
+  if ((options & WNOWAIT) == 0)
+    {
+      group_remove_child(rtcb->group, child->ch_pid);
+      group_free_child(child);
+    }
 }
 #endif
 
@@ -117,7 +122,7 @@ int waittcb(FAR struct tcb_s *rtcb, idtype_t idtype, int options,
                * Return the exit status and break out of the loop.
                */
 
-              exited_child(rtcb, child, info);
+              exited_child(rtcb, child, info, options);
               break;
             }
         }
@@ -141,7 +146,7 @@ int waittcb(FAR struct tcb_s *rtcb, idtype_t idtype, int options,
                * of the loop.
                */
 
-              exited_child(rtcb, child, info);
+              exited_child(rtcb, child, info, options);
               break;
             }
         }
@@ -232,7 +237,7 @@ int waittcb(FAR struct tcb_s *rtcb, idtype_t idtype, int options,
 
                       if ((child->ch_flags & CHILD_FLAG_EXITED) != 0)
                         {
-                          exited_child(rtcb, child, NULL);
+                          exited_child(rtcb, child, NULL, options);
                         }
                     }
 #endif
@@ -255,7 +260,7 @@ int waittcb(FAR struct tcb_s *rtcb, idtype_t idtype, int options,
                   if (child &&
                       (child->ch_flags & CHILD_FLAG_EXITED) != 0)
                     {
-                      exited_child(rtcb, child, NULL);
+                      exited_child(rtcb, child, NULL, options);
                     }
                 }
 #endif
@@ -369,7 +374,7 @@ int waitid(idtype_t idtype, id_t id, FAR siginfo_t *info, int options)
 
   if ((idtype == P_PID || idtype == P_ALL) &&
       (options & WEXITED) != 0 &&
-      (options & ~(WEXITED | WNOHANG)) == 0)
+      (options & ~(WEXITED | WNOHANG | WNOWAIT)) == 0)
 #endif
     {
       errcode = OK;


(nuttx) 01/04: sched: fix parent process check using wrong pid field

Posted by xi...@apache.org.
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

commit 91b4b0a91e57c67bda39b7270a25ec6437ff3810
Author: yushuailong <yy...@qq.com>
AuthorDate: Thu Sep 10 15:57:45 2026 +0800

    sched: fix parent process check using wrong pid field
    
    Compare ctcb->group->tg_ppid against rtcb->group->tg_pid (the group
    leader PID) instead of rtcb->pid in waitid() and in the
    !CONFIG_SCHED_CHILD_STATUS path of waitpid(). Commit ece224a7e3
    ("handle waitpid waitting tcb->group is NULL") rewrote the
    comparisons this way when adding the ctcb->group NULL guard,
    regressing what 90be95bb89 had correct: a non-group-leader thread
    calling waitid(P_PID) or waitpid() on a child always gets ECHILD.
    
    Assisted-by: OpenAI Codex
    Signed-off-by: yushuailong <yy...@qq.com>
---
 sched/sched/sched_waitid.c  | 5 +++--
 sched/sched/sched_waitpid.c | 3 ++-
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/sched/sched/sched_waitid.c b/sched/sched/sched_waitid.c
index 81955e44d15..330f26afec6 100644
--- a/sched/sched/sched_waitid.c
+++ b/sched/sched/sched_waitid.c
@@ -400,7 +400,7 @@ int waitid(idtype_t idtype, id_t id, FAR siginfo_t *info, int options)
             {
               /* Make sure that the thread it is our child. */
 
-              if (ctcb->group->tg_ppid != rtcb->pid)
+              if (ctcb->group->tg_ppid != rtcb->group->tg_pid)
                 {
                   errcode = ECHILD;
                 }
@@ -437,7 +437,8 @@ int waitid(idtype_t idtype, id_t id, FAR siginfo_t *info, int options)
 
           ctcb = nxsched_get_tcb((pid_t)id);
 
-          if (!ctcb || !ctcb->group || ctcb->group->tg_ppid != rtcb->pid)
+          if (!ctcb || !ctcb->group ||
+              ctcb->group->tg_ppid != rtcb->group->tg_pid)
             {
               errcode = ECHILD;
             }
diff --git a/sched/sched/sched_waitpid.c b/sched/sched/sched_waitpid.c
index 49a70fe974d..25e326c36f1 100644
--- a/sched/sched/sched_waitpid.c
+++ b/sched/sched/sched_waitpid.c
@@ -373,7 +373,8 @@ pid_t nxsched_waitpid(pid_t pid, FAR int *stat_loc, int options)
        */
 
       ctcb = nxsched_get_tcb(pid);
-      if (!ctcb || !ctcb->group || ctcb->group->tg_ppid != rtcb->pid ||
+      if (!ctcb || !ctcb->group ||
+          ctcb->group->tg_ppid != rtcb->group->tg_pid ||
           (ctcb->flags & TCB_FLAG_EXIT_PROCESSING) != 0)
         {
           ret = -ECHILD;


(nuttx) 03/04: sched/cpuload: fix hardcoded 100000 should be USEC_PER_SEC

Posted by xi...@apache.org.
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

commit 1a7a1891364b729eda2835992de0d82bd7611971
Author: yushuailong <yy...@qq.com>
AuthorDate: Thu Sep 10 15:56:08 2026 +0800

    sched/cpuload: fix hardcoded 100000 should be USEC_PER_SEC
    
    Replace a literal 100000 with the USEC_PER_SEC macro in the oneshot
    timer restart calculation. This bug causes incorrect timeout values
    when CONFIG_SCHED_CPULOAD_TICKSPERSEC=1, though defaults are not
    affected. Present since 2016 (commit 300361539a).
    
    Assisted-by: OpenAI Codex
    Signed-off-by: yushuailong <yy...@qq.com>
---
 sched/sched/sched_cpuload_oneshot.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sched/sched/sched_cpuload_oneshot.c b/sched/sched/sched_cpuload_oneshot.c
index 1326a32facc..b17da3c2313 100644
--- a/sched/sched/sched_cpuload_oneshot.c
+++ b/sched/sched/sched_cpuload_oneshot.c
@@ -194,7 +194,7 @@ static void nxsched_oneshot_start(void)
   /* Then re-start the oneshot timer */
 
   secs       = USEC2SEC(usecs);
-  usecs     -= 100000 * secs;
+  usecs     -= USEC_PER_SEC * secs;
 
   ts.tv_sec  = secs;
   ts.tv_nsec = 1000 * usecs;


(nuttx) 02/04: sched/sched: fix NULL param dereference in sched_setscheduler

Posted by xi...@apache.org.
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

commit 7260437f7d6913cc884523a396cc9eb2252e390c
Author: yushuailong <yy...@qq.com>
AuthorDate: Thu Sep 10 15:57:03 2026 +0800

    sched/sched: fix NULL param dereference in sched_setscheduler
    
    Add a NULL check for the param argument before dereferencing
    param->sched_priority. The sibling functions sched_setparam and
    sched_getparam already have this check; sched_setscheduler was
    the only one missing it, allowing a NULL pointer dereference
    via sched_setscheduler(0, SCHED_FIFO, NULL).
    
    Assisted-by: OpenAI Codex
    Signed-off-by: yushuailong <yy...@qq.com>
---
 sched/sched/sched_setscheduler.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/sched/sched/sched_setscheduler.c b/sched/sched/sched_setscheduler.c
index 181641c7b48..c5a7ec74be8 100644
--- a/sched/sched/sched_setscheduler.c
+++ b/sched/sched/sched_setscheduler.c
@@ -172,6 +172,11 @@ int nxsched_set_scheduler(pid_t pid, int policy,
   irqstate_t flags;
   int ret = -EINVAL;
 
+  if (param == NULL)
+    {
+      return -EINVAL;
+    }
+
   /* Check if the task to modify the calling task */
 
   if (pid == 0)