casaroli opened a new pull request, #20955: URL: https://github.com/apache/nuttx/pull/20955
## Summary When a thread unblocks a pending signal, `nxsig_unmask_pendingsignal()` takes the entry of the signal off the pending list, dispatches the signal, and then releases the entry. When the action of the signal ends the process (the default action of SIGTERM, SIGINT or SIGKILL), `nxsig_tcbdispatch()` does not return, and the entry is never released: one entry is lost each time, first from the preallocated pool, then from the kernel heap. A shell blocks signals around its commands, so `kill -TERM $$` in a shell script loses one entry each time. This PR copies the signal information and releases the entry before the dispatch. ## Impact All build modes and architectures. No change in behavior, except that the entry is released. ## Testing Test program `sigleak.c` on `qemu-armv8a:knsh` (QEMU with HVF, `CONFIG_SCHED_CHILD_STATUS=y`): 48 children one after the other; each child blocks SIGTERM, sends SIGTERM to itself and unblocks it, so the default action ends it. The program compares the used blocks of the kernel heap (`Kmem` in `/proc/meminfo`) before and after. | | master | this PR | |---|---|---| | children that SIGTERM ended | 48 of 48 | 48 of 48 | | kernel heap after 48 children | +48 blocks, +3456 bytes (72 per child) | +0 | | ostest, `qemu-armv8a:knsh` and `qemu-armv8a:nsh` | status 0 | status 0 | Build, each OK: `qemu-armv8a:nsh` (flat, arm64), `qemu-armv8a:knsh` (kernel, arm64), `lm3s6965-ek:qemu-protected` (protected, armv7-m), `qemu-armv7a:knsh` (kernel, armv7-a), `rv-virt:nsh64` (flat, rv64), `rv-virt:knsh64` (kernel, rv64). No new warnings. `tools/checkpatch.sh -c -u -m -g` passes. -- 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]
