Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8227577

(process) Change the way Runtime.exec functions internally

    Details

    • Subcomponent:
    • CPU:
      x86_64
    • OS:
      linux

      Description

      ADDITIONAL SYSTEM INFORMATION :
      # uname -a
      Linux vm2001 3.10.0-229.el7.x86_64 #1 SMP Thu Jan 29 18:37:38 EST 2015 x86_64 x86_64 x86_64 GNU/Linux

      # ./java/bin/java -version
      openjdk version "1.8.0_192"
      OpenJDK Runtime Environment (Zulu 8.33.0.2-linux64) (build 1.8.0_192-b01)
      OpenJDK 64-Bit Server VM (Zulu 8.33.0.2-linux64) (build 25.192-b01, mixed mode)

      A DESCRIPTION OF THE PROBLEM :
      Here is the current behavior (psuedo code)
      1. Runtime.exec(String ...args):
      2. for p in System.getEnv("PATH").split(":"):
      3. // execute syscall `execve` assuming args[1] is in every `p`.
      3. do_syscall( "execve", p + "/" + args[0], args.subArray(1))

      Problem with this behavior.
      1. Sometimes the file may not exist but the we execute a `execve` which sometime can result in EPERM. Which is not even handled correctly (We should retry)

      Expected behavior:
      1. Check whether the file exist or not before executing execve.

      Java code to reproduce
      ```
      class exec {
              public static void main(String[] a) throws Exception {
                      Runtime.getRuntime().exec(a);
              }
      }
      ```

      To execute.
      # javac exec.java
      # export PATH="/foo/bar/a.txt:$PATH"
      # strace -f -e execve -o trace java -cp . exec chmod
      # grep execve trace


        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              webbuggrp Webbug Group
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated: