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
The following commit(s) were added to refs/heads/master by this push:
new a7e83c7fb56 arch: Let pgalloc() extend the selected address
environment.
a7e83c7fb56 is described below
commit a7e83c7fb56b7a4ce09da0eab7b2cf2ee1f13b31
Author: Marco Casaroli <[email protected]>
AuthorDate: Thu Oct 8 19:34:46 2026 +0200
arch: Let pgalloc() extend the selected address environment.
pgalloc() grows a process heap for sbrk(). It extended the address
environment of the running task (addrenv_own). While exec() sets up a
new process, the caller selects the new address environment and
allocates the new process's stack from its heap. When that stack does
not fit in the initial heap, the heap must grow, but the running task is
the caller. For the kernel thread that starts init this was an
assertion; for a user task it would have grown the caller's heap.
Use the selected address environment (addrenv_curr). For a normal sbrk()
it is the same as addrenv_own.
Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Marco Casaroli <[email protected]>
---
arch/arm/src/armv7-a/arm_pgalloc.c | 6 +++---
arch/arm64/src/common/arm64_pgalloc.c | 4 ++--
arch/risc-v/src/common/riscv_pgalloc.c | 4 ++--
3 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/arch/arm/src/armv7-a/arm_pgalloc.c
b/arch/arm/src/armv7-a/arm_pgalloc.c
index fff467d0a8b..cea582657a1 100644
--- a/arch/arm/src/armv7-a/arm_pgalloc.c
+++ b/arch/arm/src/armv7-a/arm_pgalloc.c
@@ -183,10 +183,10 @@ uintptr_t pgalloc(uintptr_t brkaddr, unsigned int npages)
uintptr_t paddr;
unsigned int index;
- binfo("tcb->pid=%d tcb->group=%p\n", tcb->pid, tcb->addrenv_own);
+ binfo("tcb->pid=%d addrenv=%p\n", tcb->pid, tcb->addrenv_curr);
binfo("brkaddr=%x npages=%d\n", brkaddr, npages);
- DEBUGASSERT(tcb && tcb->addrenv_own);
- addrenv = &tcb->addrenv_own->addrenv;
+ DEBUGASSERT(tcb && tcb->addrenv_curr);
+ addrenv = &tcb->addrenv_curr->addrenv;
/* The current implementation only supports extending the user heap
* region as part of the implementation of user sbrk(). This function
diff --git a/arch/arm64/src/common/arm64_pgalloc.c
b/arch/arm64/src/common/arm64_pgalloc.c
index 8dcc12f69a4..35a5ef667a6 100644
--- a/arch/arm64/src/common/arm64_pgalloc.c
+++ b/arch/arm64/src/common/arm64_pgalloc.c
@@ -100,8 +100,8 @@ uintptr_t pgalloc(uintptr_t brkaddr, unsigned int npages)
uintptr_t paddr;
uintptr_t vaddr;
- DEBUGASSERT(tcb && tcb->addrenv_own);
- addrenv = &tcb->addrenv_own->addrenv;
+ DEBUGASSERT(tcb && tcb->addrenv_curr);
+ addrenv = &tcb->addrenv_curr->addrenv;
/* The current implementation only supports extending the user heap
* region as part of the implementation of user sbrk(). This function
diff --git a/arch/risc-v/src/common/riscv_pgalloc.c
b/arch/risc-v/src/common/riscv_pgalloc.c
index c7a5f20261b..9ebbda0ff1f 100644
--- a/arch/risc-v/src/common/riscv_pgalloc.c
+++ b/arch/risc-v/src/common/riscv_pgalloc.c
@@ -103,8 +103,8 @@ uintptr_t pgalloc(uintptr_t brkaddr, unsigned int npages)
uintptr_t paddr;
uintptr_t vaddr;
- DEBUGASSERT(tcb && tcb->addrenv_own);
- addrenv = &tcb->addrenv_own->addrenv;
+ DEBUGASSERT(tcb && tcb->addrenv_curr);
+ addrenv = &tcb->addrenv_curr->addrenv;
/* The current implementation only supports extending the user heap
* region as part of the implementation of user sbrk(). This function