You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by ac...@apache.org on 2026/10/17 22:30:20 UTC
(nuttx) 03/03: mm/mm_gran: Do not fail an allocation when a signal arrives.
This is an automated email from the ASF dual-hosted git repository.
acassis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 15a3ee13cd7eec09084b7e64dce8a1e4fee8dbf2
Author: Marco Casaroli <ma...@gmail.com>
AuthorDate: Mon Oct 12 14:45:34 2026 +0200
mm/mm_gran: Do not fail an allocation when a signal arrives.
gran_enter_critical() returned the result of nxmutex_lock(), which is
-EINTR when a signal interrupts the wait, and gran_alloc() then returned
NULL as if the pool were full. The page allocator uses a granule
allocator, so fork(), sbrk() and the stack of a new task failed with
ENOMEM while most of the page pool was free.
Retry the lock when a signal interrupts it.
Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Marco Casaroli <ma...@gmail.com>
---
mm/mm_gran/mm_grancritical.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/mm/mm_gran/mm_grancritical.c b/mm/mm_gran/mm_grancritical.c
index 06481e1de06..5a01094dbfd 100644
--- a/mm/mm_gran/mm_grancritical.c
+++ b/mm/mm_gran/mm_grancritical.c
@@ -62,7 +62,17 @@ int gran_enter_critical(FAR struct gran_s *priv)
priv->irqstate = spin_lock_irqsave(&priv->lock);
return OK;
#else
- return nxmutex_lock(&priv->lock);
+ int ret;
+
+ /* A signal must not make the allocation fail */
+
+ do
+ {
+ ret = nxmutex_lock(&priv->lock);
+ }
+ while (ret == -EINTR);
+
+ return ret;
#endif
}