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
8274548: (fc) FileChannel gathering write fails with IOException "Invalid argument" on macOS 11.6 #5831
Conversation
…alid argument" on macOS 11.6
|
The
and similarly on macOS:
On Linux, The error could be handled by a code change in Testing has verified the fix on macOS 11.6 and earlier macOS versions with no effect (of course) on Linux. |
Webrevs
|
We really need someone from Apple here to tell us if this is a man page issue or a bug in macOS 11.6. If I read it correctly, the issue doesn't occur with 10.5.x and the beta of macOS 12, is that correct? If we do need to put a workaround in for this then I think it will need an overhaul of IOUtil first. I'd prefer not have the iovec array be modified in two places. |
V1 moves the logic up to the Java level and removes all native code changes. |
Mailing list message from Brian Burkhalter on nio-dev: On Oct 5, 2021, at 11:55 PM, Alan Bateman <alanb at openjdk.java.net<mailto:alanb at openjdk.java.net>> wrote: If I read it correctly, the issue doesn't occur with 10.5.x and the best of macOS 12, is that correct? That is correct: change in behavior was seen on 11.6 only; 10.5.x and 12-beta are identical and do not manifest it. |
The latest version impacts all platforms. I think the first step here is to make contact with Apple and try to detect if this is an intended change in macOS 11.6 or not. The observation that they reverted it again in macOS 12 beta suggests it was unintentional but I think we need to find out more. |
Not affecting all platforms is why it was in the C code in the first place. Apple indicates it was an intentional change in macOS 11.x where x >= 0. I don't know yet about 12. |
My original evaluation on macOS 12-beta was incorrect: I re-tested and the problem occurs there as well. Therefore we are seeing it on |
One approach is try to add a writevMax method along side of iovMax that returns the maximum value of the sum of the iov_len. If this is merged with your v2 then it might not be too bad. |
v4 was verified to pass the test included in this PR on Linux-aarch64, Linux-x64, macOS 10.15.7 and 11.6, and Windows (Server 2016). |
// [EINVAL] The sum of the iov_len values in the iov array | ||
// overflows a 32-bit integer. | ||
// | ||
int darwin_version = get_darwin_version(); |
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.
What you would think about dropping the OS version and just return Integer.MAX_VALUE on macOS? That would align with the EINVAL documented in the man page on all versions.
In passing, an inconsistency has kept into the native code. In some places we are using ifdef APPLE and in others ifdef MACOX. We should probably clean this up.
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'm find with dropping the OS version check on macOS and removing the Darwin version function.
I also noticed the inconsistency in the APPLE and MACOSX symbolic constants. There's also another one like ALL_BSD_SOURCE. I don't know whether we consider that redundant as well.
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'm find with dropping the OS version check on macOS and removing the Darwin version function.
I think it will align with the man page and remove any questions as to why this is macOS version specific.
I also noticed the inconsistency in the APPLE and MACOSX symbolic constants. There's also another one like ALL_BSD_SOURCE. I don't know whether we consider that redundant as well.
We can look at this in a separate issue.
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.
... and dropping the OS version check leaves fewer moving parts.
On the conditional compilation symbolic constants I filed JDK-8275070.
@bplb This change now passes all automated pre-integration checks. 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 76 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.
|
/integrate |
Going to push as commit 07b1f1c.
Your commit was automatically rebased without conflicts. |
On macOS, handle the case where
writev()
is given an array ofstruct iovec
the sum of whoseiov_len
fields overflowsINT_MAX
.Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk pull/5831/head:pull/5831
$ git checkout pull/5831
Update a local copy of the PR:
$ git checkout pull/5831
$ git pull https://git.openjdk.java.net/jdk pull/5831/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 5831
View PR using the GUI difftool:
$ git pr show -t 5831
Using diff file
Download this PR as a diff file:
https://git.openjdk.java.net/jdk/pull/5831.diff