> 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:

  Remove errno preservation around file action cleanup

-------------

Changes:
  - all: https://git.openjdk.org/jdk/pull/33360/files
  - new: https://git.openjdk.org/jdk/pull/33360/files/9c02b95d..bfb7b679

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jdk&pr=33360&range=02
 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=33360&range=01-02

  Stats: 11 lines in 1 file changed: 0 ins; 8 del; 3 mod
  Patch: https://git.openjdk.org/jdk/pull/33360.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/33360/head:pull/33360

PR: https://git.openjdk.org/jdk/pull/33360

Reply via email to