-
Notifications
You must be signed in to change notification settings - Fork 6.1k
8361873: [GCC static analyzer] exec_md.c forkedChildProcess potential double 'close' of file descriptor '3' #26487
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
👋 Welcome back cjplummer! A progress list of the required criteria for merging this PR into |
@plummercj This change now passes all automated pre-integration checks. ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details. After integration, the commit message for the final commit will be:
You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed. At the time when this comment was updated there had been 16 new commits pushed to the
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details. ➡️ To integrate this PR with the above commit message to the |
@plummercj The following label will be automatically applied to this pull request:
When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command. |
Webrevs
|
* descriptors afresh. */ | ||
* descriptors afresh. | ||
* | ||
* WARNING: We are not allowed to fail until after these two closes are |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello Chris, would it be better to word this as "We are not allowed to return from this function until after ...."?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The issue is returning with a failure, not simply returning early, although it should only ever return early if there is a failure. I can change "not allowed to fail" with "not allowed to return with a failure"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can change "not allowed to fail" with "not allowed to return with a failure"
That sounds good to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks reasonable to me. I just have trivial comment about the code comment introduced in this change, which I've added inline.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me.
Note that in the official Runtime.exec layer over in libjava, we switched to setting the filedescriptors to FD_CLOEXEC, which seems more elegant and circumvents this and some other problems.
Are you talking about what is being done in os::open()? What about opens done that don't go through os::open() such as opens from app native code? In any case, I think this is beyond the scope of this PR. Maybe an RFE could be filed for it if you think it is worth doing. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you Chris for the update. This looks good to me.
No, I am talking about this:
where we close all file descriptors apart from the ones we need to communicate to the jspawnhelper.
Sure thing |
Fix gcc warning about double close. forkedChildProcess() calls closeDescriptors(), which always closes STDERR_FILENO + 1 and STDERR_FILENO + 2. However, if it fails at some point after that, then forkedChildProcess() will attempt to close these same two files again. Fixed by making forkedChildProcess() no longer attempt to close these two files.
I first verified the warning by configuring with --with-extra-cflags=-fanalyzer, and then verified the fix by doing the same.
Tested by running jdi nsk test. I'll add some more CI testing.
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/26487/head:pull/26487
$ git checkout pull/26487
Update a local copy of the PR:
$ git checkout pull/26487
$ git pull https://git.openjdk.org/jdk.git pull/26487/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 26487
View PR using the GUI difftool:
$ git pr show -t 26487
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/26487.diff
Using Webrev
Link to Webrev Comment