casaroli opened a new pull request, #20717: URL: https://github.com/apache/nuttx/pull/20717
## Summary When `addrenv_fork()` failed, `nxtask_setup_fork()` still called `fork_restore_parent_env()`. `addrenv_restore()` then gave back a reference to the parent's address environment that `addrenv_select()` never took. When the parent exited, its address environment was destroyed while a CPU still had it selected, and the next switch to it found no page tables (`up_addrenv_select()` assertion). This PR restores the parent's environment only if the child has one. ## Impact Only the error path of `fork()` in builds with `CONFIG_ARCH_ADDRENV` changes. The bug came with `fork()` for address environments (#19562). ## 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` (`addrenv_fork()` failing at random): before, the parent's address environment was later destroyed while selected and `up_addrenv_select()` asserted; with the change, 4 injection runs with 30 failed `fork()` calls completed with no assertion. -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
