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

[PR] sched/task: Return ENOMEM when the stack of a new task cannot be allocated. [nuttx]

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

   ## Summary
   
   `up_create_stack()` returns `ERROR` (-1) on every architecture, and `nxtask_init()` and `nxtask_setup_fork()` passed that value on as a negated errno. So `exec()`, `task_create()` and `fork()` failed with `EPERM` ("Operation not permitted") when the stack could not be allocated. `pthread_create()` already returns `ENOMEM` in this case.
   
   This PR returns `-ENOMEM`.
   
   ## Impact
   
   Only the error code changes: callers now see `ENOMEM` instead of `EPERM` when a stack allocation fails.
   
   ## Testing
   
   Builds: `qemu-armv8a:nsh`, `qemu-armv8a:knsh`, `lm3s6965-ek:qemu-flat`.
   
   Runtime, QEMU 11 with HVF on an Apple M4: `ostest` on `qemu-armv8a:knsh` (kernel build) and `qemu-armv8a:nsh` (flat build) ends with `ostest_main: Exiting with status 0`.
   
   `tools/checkpatch.sh -c -u -m -g` passes.
   
   The error path was reached with page-allocation fault injection on `qemu-armv8a:knsh` (a failing stack allocation in `fork()` and `exec()`): before, the programs reported "Operation not permitted"; with the change, "Out of memory".
   


-- 
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] arch: Return -ENOMEM when up_create_stack() cannot allocate the stack. [nuttx]

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


-- 
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/task: Return ENOMEM when the stack of a new task cannot be allocated. [nuttx]

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


##########
sched/task/task_fork.c:
##########
@@ -359,6 +359,7 @@ FAR struct tcb_s *nxtask_setup_fork(start_t retaddr, bool vfork)
 
   if (ret < OK)
     {
+      ret = -ENOMEM;

Review Comment:
   let's correct up_create_stack return value 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


Re: [PR] sched/task: Return ENOMEM when the stack of a new task cannot be allocated. [nuttx]

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

   <!-- 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=4604a308d139c79611d3a1666485fa9448ccdb42&base=17747ded0aaba11af1dd07422c15354200e65e3e)
     - **flash**: .text +6 B (+0.0%, 64,984 B / 262,144 B, total: 25% used)
   ### [esp32-devkitc](https://membrowse.com/public/apache/nuttx/target/esp32-devkitc/compare?head=4604a308d139c79611d3a1666485fa9448ccdb42&base=17747ded0aaba11af1dd07422c15354200e65e3e)
     - **ROM**: .flash.text +8 B (+0.0%, 126,192 B / 4,194,272 B, total: 3% used)
     - **irom0_0_seg**: .flash.text +8 B (+0.0%, 90,388 B / 3,342,304 B, total: 3% used)
   ### [mirtoo](https://membrowse.com/public/apache/nuttx/target/mirtoo/compare?head=4604a308d139c79611d3a1666485fa9448ccdb42&base=17747ded0aaba11af1dd07422c15354200e65e3e)
     - **kseg0_progmem**: .text +20 B (+0.0%, 67,164 B / 131,072 B, total: 51% used)
   ### [qemu-armv8a](https://membrowse.com/public/apache/nuttx/target/qemu-armv8a/compare?head=4604a308d139c79611d3a1666485fa9448ccdb42&base=17747ded0aaba11af1dd07422c15354200e65e3e)
     - **Code**: .text.nxtask_init +4 B (+0.0%, 348,416 B)
   ### [qemu-intel64](https://membrowse.com/public/apache/nuttx/target/qemu-intel64/compare?head=4604a308d139c79611d3a1666485fa9448ccdb42&base=17747ded0aaba11af1dd07422c15354200e65e3e)
     - **Code**: .text +16 B (+0.0%, 8,683,470 B)
   ### [stm32-nucleo-f103rb](https://membrowse.com/public/apache/nuttx/target/stm32-nucleo-f103rb/compare?head=4604a308d139c79611d3a1666485fa9448ccdb42&base=17747ded0aaba11af1dd07422c15354200e65e3e)
     - **flash**: .text +8 B (+0.0%, 34,460 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=4604a308d139c79611d3a1666485fa9448ccdb42&base=17747ded0aaba11af1dd07422c15354200e65e3e)
   - [rx65n-rsk2mb](https://membrowse.com/public/apache/nuttx/target/rx65n-rsk2mb/compare?head=4604a308d139c79611d3a1666485fa9448ccdb42&base=17747ded0aaba11af1dd07422c15354200e65e3e)
   - [s698pm-dkit](https://membrowse.com/public/apache/nuttx/target/s698pm-dkit/compare?head=4604a308d139c79611d3a1666485fa9448ccdb42&base=17747ded0aaba11af1dd07422c15354200e65e3e)
   


-- 
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/task: Return ENOMEM when the stack of a new task cannot be allocated. [nuttx]

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


##########
sched/task/task_fork.c:
##########
@@ -359,6 +359,7 @@ FAR struct tcb_s *nxtask_setup_fork(start_t retaddr, bool vfork)
 
   if (ret < OK)
     {
+      ret = -ENOMEM;

Review Comment:
   Done. `up_create_stack()` now returns `-ENOMEM` on all architectures, and the callers pass the value on.



-- 
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