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

(process) Windows Process.exitValue() has poor error handling

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 6
    • Fix Version/s: 7
    • Component/s: core-libs
    • Labels:
      None
    • Subcomponent:
    • Resolved In Build:
      b15
    • CPU:
      generic
    • OS:
      generic

      Description

      The implementation of exitValue() is not careful enough to check for errors.

      JNIEXPORT jint JNICALL
      Java_java_lang_ProcessImpl_exitValue(JNIEnv *env, jobject process)
      {
          jint exit_code;
          jboolean exc;
          jlong handle = JNU_GetFieldByName(env, &exc, process, "handle", "J").j;
          if (exc) {
              return 0;
          }

          GetExitCodeProcess((void *)handle, &exit_code);
          if (exit_code == STILL_ACTIVE) {
      JNU_ThrowByName(env, "java/lang/IllegalThreadStateException",
      "process has not exited");
      return -1;
          }
          return exit_code;
      }

      What happens if GetExitCodeProcess fails?
      In this case there should be an exception thrown with a human-readable
      error description.
      Also, in this case exit_code may never be initialized, with the result that the
      returned value is whatever random garbage was on the stack at the point of call.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              martin Martin Buchholz
              Reporter:
              martin Martin Buchholz
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: