On Fri, 30 Oct 2026 13:09:30 GMT, Lee Jiwon <[email protected]> wrote:
>> JDK-8377907 added file actions to spawnChild() without cleanup. This patch >> destroys them at both adddup2 error exits and immediately after >> posix_spawn(). >> >> The cleanup helper preserves errno so it does not change the IOException >> diagnostics in forkAndExec(). >> >> ### Testing >> >> macOS 26.2/aarch64, release build. Before: JDK 27+35-2325. After: commit >> 1077a0ab5ec. >> >> make exploded-test TEST="jtreg:test/jdk/java/lang/ProcessBuilder": 26 >> passed, 0 failed, 13 not run. >> >> Manual checks used MallocStackLogging=1 and `leaks --fullStacks <PID>`. >> Counts sum all ROOT LEAK groups labeled realloc in >> _posix_spawn_file_actions_grow. The successful-launch Before result and >> reproducer are attached to >> [JDK-8394402](https://bugs.openjdk.org/browse/JDK-8394402). >> >> | Scenario | Before | After | >> |---|---:|---:| >> | 110 successful launches | 110 | 0 | >> | 50 first-adddup2 failures | 50 | 0 | >> | 50 fifth-adddup2 failures | 50 | 0 | >> >> The adddup2 failures used a DYLD_INSERT_LIBRARIES interposer returning EBADF >> for newfd=0 or newfd=3. >> >> No automated regression test is included: NMT does not track these libc >> allocations, and the manual checks use macOS tools. >> [JDK-8311645](https://bugs.openjdk.org/browse/JDK-8311645) used noreg-hard >> for a leak in the same function. >> >> GitHub Actions: Linux x64 builds and tier1 passed. >> >> Native leaks were not measured on Linux or AIX. >> >> --------- >> - [x] I confirm that I make this contribution in accordance with the >> [OpenJDK Interim AI Policy](https://openjdk.org/legal/ai). > > Lee Jiwon has updated the pull request incrementally with one additional > commit since the last revision: > > Check posix_spawn_file_actions_init return value I think your changes look good. But I just re-read the man page for `posix_spawn_file_actions_destroy()` and it says: "*Upon successful completion, these functions shall return zero; otherwise, an error number shall be returned to indicate the error*". And that's actually the case for all file action functions. This means that you don't even have to bother about saving/restoring `errno` and the function name and comment can't be simplified to omit the `errno` part. ------------- Changes requested by simonis (Reviewer). PR Review: https://git.openjdk.org/jdk/pull/33360#pullrequestreview-5715932462
