[JIRA] (JENKINS-59580) NPE in OSProcess#hasMatchingEnvVars on Windows

8 views
Skip to first unread message

marat@slonopotamus.org (JIRA)

unread,
Sep 30, 2019, 2:38:02 AM9/30/19
to jenkinsc...@googlegroups.com
Marat Radchenko created an issue
 
Jenkins / Bug JENKINS-59580
NPE in OSProcess#hasMatchingEnvVars on Windows
Issue Type: Bug Bug
Assignee: Unassigned
Components: core
Created: 2019-09-30 06:37
Environment: Windows, Jenkins Core master from GitHub
Priority: Major Major
Reporter: Marat Radchenko

Reproducing code:

        OUTER:
        while (true) {
            for (OSProcess proc : ProcessTree.get()) {
                if (proc.hasMatchingEnvVars(Collections.singletonMap("foo", "bar"))) {
                    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.

Add Comment Add Comment
 
This message was sent by Atlassian Jira (v7.13.6#713006-sha1:cc4451f)
Atlassian logo

marat@slonopotamus.org (JIRA)

unread,
Sep 30, 2019, 2:48:02 AM9/30/19
to jenkinsc...@googlegroups.com
Marat Radchenko updated an issue
Change By: Marat Radchenko
Reproducing code:

{code}        OUTER:

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


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.

marat@slonopotamus.org (JIRA)

unread,
Oct 2, 2019, 4:18:03 AM10/2/19
to jenkinsc...@googlegroups.com
Change By: Marat Radchenko
Status: Open Fixed but Unreleased
Resolution: Fixed
Released As: 2.199

dbeck@cloudbees.com (JIRA)

unread,
Oct 7, 2019, 4:10:04 AM10/7/19
to jenkinsc...@googlegroups.com

o.v.nenashev@gmail.com (JIRA)

unread,
Oct 7, 2019, 8:16:02 PM10/7/19
to jenkinsc...@googlegroups.com

ogondza@gmail.com (JIRA)

unread,
Oct 8, 2019, 8:39:04 AM10/8/19
to jenkinsc...@googlegroups.com
Oliver Gondža updated an issue
Change By: Oliver Gondža
Labels: lts 2.190.2 - candidate fixed
Reply all
Reply to author
Forward
0 new messages