JDK-8210051 : Java inherits handle of "modules" file to sub-processes
  • Type: Bug
  • Component: tools
  • Sub-Component: jlink
  • Affected Version: 10.0.2
  • Priority: P4
  • Status: Resolved
  • Resolution: Duplicate
  • OS: windows_10
  • CPU: x86_64
  • Submitted: 2018-08-27
  • Updated: 2018-08-28
  • Resolved: 2018-08-28
Related Reports
Duplicate :  
Description
A DESCRIPTION OF THE PROBLEM :
The JavaVM opens a handle to the file "lib/modules" and sets its inherit attribute to true. As the java.lang.ProcessBuilder also executes new processes with the inherit flag set to true, this handle is inherited to subprocesses. See http://hg.openjdk.java.net/jdk10/sandbox/jdk/file/94d5e1b00394/src/java.base/windows/native/libjava/ProcessImpl_md.c
So subprocesses are not able to modify/delete this file. 
My usecase: From a hostapp I want to execute a Updater-App with a separate java installation and then let the Updater install a new hostapp version. Therefore I also need to replace the java binaries of the standalone hostapp.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
You need two java installations (first one must be Java10)
- Create a simple app that runs an infinite loop (App2)
- Create another app (App1) that executes App2 with java.lang.ProcessBuilder and then exits. Use the second VM to execute the app. 
- Execute App1 in the first VM
- Use a tool like ProcessHacker to find all open handles of the running App2
-> You will see that there is an open handle to the file "modules" of the Java10 installation



EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The JavaVM should not open inherited handles on files. Also ProcessBuilder should not inherit handles to subprocesses.
ACTUAL -
The JavaVM opens inherited handles on the file "lib/modules". ProcessBuilder inherits handles to subprocesses.

FREQUENCY : always



Comments
This is fixed in JDK 11 via JDK-8194734.
28-08-2018