JDK-8324668 : JDWP process management needs more efficient file descriptor handling
  • Type: Enhancement
  • Component: core-svc
  • Sub-Component: debugger
  • Affected Version: 23
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2024-01-25
  • Updated: 2024-06-12
  • Resolved: 2024-02-01
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 17 JDK 21 JDK 23
17.0.13Fixed 21.0.5-oracleFixed 23 b09Fixed
Related Reports
Blocks :  
Relates :  
Relates :  
Relates :  
Description
After the fix for JDK-8300088 some JDI/JDWP tests started exhibiting timeouts.

[~jpai] reports:

The root cause is this code in  jdwp which does the work of launching a process (passed as a command to launch=cmdline option) 

https://github.com/openjdk/jdk/blob/master/src/jdk.jdwp.agent/unix/native/libjdwp/exec_md.c#L103. 

it forks the child process and then goes ahead to close all possible file descriptor copies (from its parent) of this newly created child process. to do that it fetches the max number of allowed open descriptors (sysconf) and then iterates over it one by one (starting fd=3) to close them all. before the change in JDK-8300088, the max_fd value in that loop used to be relatively smaller 10240 and it appears that it was able to close them all in a reasonable amount of time. however, now the value returned there for max_fd is 2147483647 and by the time the test times out, that loop has only been able to close around 26839415 odd file descriptors and is still continuing to close the rest 

I had a quick look at how we handle forking in other APIs in the JDK and turns out there is a more optimal way we do it in the Process impl native code https://github.com/openjdk/jdk/blob/master/src/java.base/unix/native/libjava/childproc.c#L74
Comments
[jdk17u-fix-request] Approval Request from Dmitry Cherepanov This is a prerequisite change for JDK-8324577 (already backported to JDK 21). Applies cleanly except for copyright years. Passes local tier1-4 testing on macos-aarch64.
12-06-2024

A pull request was submitted for review. URL: https://git.openjdk.org/jdk17u-dev/pull/2557 Date: 2024-06-10 07:46:31 +0000
10-06-2024

[jdk21u-fix-request] Approval Request from Martin Should get backported for parity with 21.0.5-oracle. Applies cleanly and tier1-4 have passed.
30-05-2024

A pull request was submitted for review. URL: https://git.openjdk.org/jdk21u-dev/pull/619 Date: 2024-05-29 16:29:00 +0000
29-05-2024

Changeset: a6632487 Author: Jaikiran Pai <jpai@openjdk.org> Date: 2024-02-01 05:55:58 +0000 URL: https://git.openjdk.org/jdk/commit/a6632487863db5ff3136cdcc76b7440c15ce6be9
01-02-2024

A pull request was submitted for review. URL: https://git.openjdk.org/jdk/pull/17588 Date: 2024-01-26 14:52:49 +0000
26-01-2024

[~jpai] provided the attached patch with the note: Attempted this extremely crude patch in the jdwp exec code to mimic what we do in the process impl's fork implementation. this gets all those 3 failing tests to pass locally, both with and without the changes that were done in JDK-8300088. of course, this patch will need more cleanup (i even didn't consider AIX in this attempt, so that code too needs to be borrowed over). plus the cast to int for the max_fd probably needs a rethought, perhaps
25-01-2024