casaroli opened a new pull request, #21017: URL: https://github.com/apache/nuttx/pull/21017
## Summary `group_release()` freed the task information (environment, streams) before it closed the files of the group. With `CONFIG_FS_NOTIFY`, the close of a file queues a notification with the path of the file. A path that is not absolute (a pipe) needs the current directory: `lib_realpath()` calls `getcwd()`, which reads `PWD` from the environment of the group under the lock of the task information. At process exit that memory was already free, so a process that ended with an open pipe could wait for ever on a lock in freed memory, and its memory was not released. This PR closes the files first and then releases the task information. ## Impact All build modes and architectures; the problem shows only with `CONFIG_FS_NOTIFY`. No interface changes. The other steps of `group_release()` keep their order. ## Testing Test program `exitwrite.c` on `qemu-armv8a:knsh` (QEMU with HVF, `CONFIG_PIPES`, `CONFIG_SCHED_CHILD_STATUS`): 5 times a child that writes a file and exits with it open, and 5 times a child that writes a pipe and exits with it open. Each child must go away (`/proc/<pid>` disappears after `waitpid()`). | | master | this PR | |---|---|---| | file children, `CONFIG_FS_NOTIFY=y` | 5 of 5 go away | 5 of 5 go away | | pipe children, `CONFIG_FS_NOTIFY=y` | 0 of 5 go away (each stays in `/proc`) | 5 of 5 go away | | pipe children, without `CONFIG_FS_NOTIFY` | 5 of 5 go away | | | ostest, `qemu-armv8a:knsh` and `qemu-armv8a:nsh` (`CONFIG_FS_NOTIFY=y`) | | status 0 | Build, each OK: `qemu-armv8a:nsh` (flat, arm64), `qemu-armv8a:knsh` (kernel, arm64), `rv-virt:pnsh64` (protected, rv64), `rv-virt:knsh64` (kernel, rv64), all with `CONFIG_FS_NOTIFY`. `lm3s6965-ek:qemu-protected` (protected, armv7-m) does not link on master today: its user flash overflows (772 bytes with Arm GNU 13.2, as in CI). This PR changes only kernel code: with Arm GNU 15.3, master and this PR overflow by the same 1036 bytes. `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]
