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:59 UTC
[PR] sched/semaphore, mm: Do not let a pending signal break a lock wait. [nuttx]
casaroli opened a new pull request, #20719:
URL: https://github.com/apache/nuttx/pull/20719
## Summary
Three fixes for lock waits that a signal could break.
1. `sched/semaphore`: `nxsem_wait_slow()` returns `-EINTR` at once when an unmasked signal is pending. During a system call such a signal stays pending until the call returns, so kernel code that retries a mutex wait (as `mm_lock()` does) looped. In a critical section the holder of the mutex could then not run: a 4-CPU arm64 target stopped this way. A mutex wait no longer makes this check; a signal that arrives during the wait still wakes the task through `nxsem_wait_irq()`.
2. `mm/mm_heap`: `mm_lock()` returned 0 even when `nxmutex_lock()` failed with `-EINTR`, so a task could change the heap without the lock. With SMP, parallel process creation corrupted the heap within seconds. It now retries.
3. `mm/mm_gran`: `gran_enter_critical()` returned `-EINTR`, and `gran_alloc()` then returned NULL as if the pool were full: `fork()`, `sbrk()` and new stacks failed with `ENOMEM` while most pages were free. It now retries.
The order matters: 2 and 3 alone make the loop of 1 permanent, so the three go together.
## Impact
Heap and page-allocator locks are no longer lost or failed by signals. No API change.
## 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 hang was found on `qemu-armv8a:knsh` with 4 CPUs, with many processes created and reaped in parallel: all CPUs waited on the critical section while one looped in `mm_lock()`. With the three commits the same load runs to the end; without the `mm_lock()`/`gran` retries the heap was corrupted within seconds.
--
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/semaphore, mm: Do not let a pending signal break a lock wait. [nuttx]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #20719:
URL: https://github.com/apache/nuttx/pull/20719#issuecomment-6237556433
<!-- membrowse-pr-comment -->
## <img src="https://membrowse.com/membrowse-logo.svg" height="24" align="top"> MemBrowse Memory Report
### [esp32-devkitc](https://membrowse.com/public/apache/nuttx/target/esp32-devkitc/compare?head=30e2d0169d865ad782a07cad2700d7fbc2176427&base=17747ded0aaba11af1dd07422c15354200e65e3e)
- **ROM**: .flash.text +16 B (+0.0%, 126,200 B / 4,194,272 B, total: 3% used)
- **irom0_0_seg**: .flash.text +16 B (+0.0%, 90,396 B / 3,342,304 B, total: 3% used)
### [mirtoo](https://membrowse.com/public/apache/nuttx/target/mirtoo/compare?head=30e2d0169d865ad782a07cad2700d7fbc2176427&base=17747ded0aaba11af1dd07422c15354200e65e3e)
- **kseg0_progmem**: .text +24 B (+0.0%, 67,168 B / 131,072 B, total: 51% used)
### [qemu-armv8a](https://membrowse.com/public/apache/nuttx/target/qemu-armv8a/compare?head=30e2d0169d865ad782a07cad2700d7fbc2176427&base=17747ded0aaba11af1dd07422c15354200e65e3e)
- **Code**: .text.mm_lock +4 B, .text.nxsem_wait_slow +4 B (+0.0%, 348,420 B)
### [s698pm-dkit](https://membrowse.com/public/apache/nuttx/target/s698pm-dkit/compare?head=30e2d0169d865ad782a07cad2700d7fbc2176427&base=17747ded0aaba11af1dd07422c15354200e65e3e)
- **Code**: .text +48 B (+0.0%, 375,824 B)
### [stm32-nucleo-f103rb](https://membrowse.com/public/apache/nuttx/target/stm32-nucleo-f103rb/compare?head=30e2d0169d865ad782a07cad2700d7fbc2176427&base=17747ded0aaba11af1dd07422c15354200e65e3e)
- **flash**: .text +12 B (+0.0%, 34,464 B / 131,072 B, total: 26% used)
*No memory changes detected for:*
- [arduino-mega2560](https://membrowse.com/public/apache/nuttx/target/arduino-mega2560/compare?head=30e2d0169d865ad782a07cad2700d7fbc2176427&base=17747ded0aaba11af1dd07422c15354200e65e3e)
- [hifive1-revb](https://membrowse.com/public/apache/nuttx/target/hifive1-revb/compare?head=30e2d0169d865ad782a07cad2700d7fbc2176427&base=17747ded0aaba11af1dd07422c15354200e65e3e)
- [qemu-intel64](https://membrowse.com/public/apache/nuttx/target/qemu-intel64/compare?head=30e2d0169d865ad782a07cad2700d7fbc2176427&base=17747ded0aaba11af1dd07422c15354200e65e3e)
- [rx65n-rsk2mb](https://membrowse.com/public/apache/nuttx/target/rx65n-rsk2mb/compare?head=30e2d0169d865ad782a07cad2700d7fbc2176427&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/semaphore, mm: Do not let a pending signal break a lock wait. [nuttx]
Posted by "acassis (via GitHub)" <gi...@apache.org>.
acassis merged PR #20719:
URL: https://github.com/apache/nuttx/pull/20719
--
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