Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-59580

NPE in OSProcess#hasMatchingEnvVars on Windows

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Fixed
    • Component/s: core
    • Labels:
    • Environment:
      Windows, Jenkins Core master from GitHub
    • Similar Issues:
    • Released As:
      2.199

      Description

      Reproducing code:

              OUTER:
              while (true) {
                  for (OSProcess proc : ProcessTree.get()) {
                      if (proc.hasMatchingEnvVars(Collections.singletonMap("foo", "bar"))) { //-------- fails with NPE
                          break OUTER;
                      }
                  }
              }

      Analysis:
      1. OSProcess#hasMatchingEnvVars assumes that OSProcess#getEnvironmentVariables never returns null (and its Javadoc says so).
      2. There's a time frame between ProcessTree.get() and call to getEnvironmentVariables
      3. If proccess exits during this timeframe, an exception is thrown by org.jvnet.winp.WinProcess#getEnvironmentVariables, propagated through WindowsOSProcess#getEnvironmentVariables2, then caught in WindowsOSProcess#getEnvironmentVariables
      4. And finally, WindowsOSProcess#getEnvironmentVariables returns null, thus violating contract from superclass Javadoc.

        Attachments

          Issue Links

            Activity

            There are no comments yet on this issue.

              People

              • Assignee:
                Unassigned
                Reporter:
                slonopotamusorama Marat Radchenko
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: