-
Notifications
You must be signed in to change notification settings - Fork 148
JDK-8265369 [macos-aarch64] java/net/MulticastSocket/Promiscuous.java failed with "SocketException: Cannot allocate memory" #44
Conversation
… failed with "SocketException: Cannot allocate memory The test java/net/MulticastSocket/Promiscuous.java has been observed to fail on a regular basis on macosx-aarch. This is typically under have test load on a test machine. Analysis of the problem have shown that the setsockopt for joining a multicast group will intermittently fail with ENOMEM. The proposed fix is in open/src/java.base/unix/native/libnet/PlainDatagramSocketImpl.c in the mcast_join_leave function. The change has been applied as a conditional compilation. Additionally this change result in the Promiscuous.java test being removed from the ProblemList.txt.
👋 Welcome back msheppar! A progress list of the required criteria for merging this PR into |
… failed with "SocketException: Cannot allocate memory" Remove trailing white spaces
… failed with "SocketException: Cannot allocate memory" Remove another trailing white spaces
Webrevs
|
} | ||
} | ||
} else { | ||
#endif |
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 handling of ENOMEM here is consistent with how it is handled in the NIO area - good.
I wonder if a little restructuring may simplify the call flow? For example, something similar to:
int n;
...
/*
* Join the multicast group.
*/
n = setsockopt(fd, IPPROTO_IP, (join ? IP_ADD_MEMBERSHIP:IP_DROP_MEMBERSHIP),
(char *) &mname, mname_len);
#ifdef __APPLE__
// workaround macOS bug where IP_ADD/DROP_MEMBERSHIP fails intermittently
if (n < 0 && errno == ENOMEM) {
n = setsockopt(fd, IPPROTO_IP, (join ? IP_ADD_MEMBERSHIP:IP_DROP_MEMBERSHIP),
(char *) &mname, mname_len);
}
#endif
if (n < 0) { ...
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.
yes, I'll do that ... originally I did this but reverted to current change to retain the current structure of the file
thanks for the suggestion, it is much neater
… failed with "SocketException: Cannot allocate memory" amendments as per suggestion from Chris Hegarty
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.
Thanks for the update Mark. It makes the code much easier to follow.
@msheppar 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 48 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 |
@@ -1837,6 +1837,9 @@ static void mcast_join_leave(JNIEnv *env, jobject this, | |||
jint fd; | |||
jint family; | |||
jint ipv6_join_leave; | |||
#ifdef __APPLE__ | |||
int res; | |||
#endif | |||
|
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.
res will need to be declared unconditionally, no? ( since it is used on all platforms )
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.
yes ... good spot 👍 ..... as testing has been focused on macos, this error didn't show
if (join) { | ||
NET_ThrowCurrent(env, "setsockopt " S_ADD_MEMBERSHIP " failed"); | ||
NET_ThrowCurrent(env, "setsockopt " S_ADD_MEMBERSHIP " failed"); | ||
} else { |
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.
Accidental indentation here? ( four spaces added in front of NET_ThrowCurrent )
if (setsockopt(fd, IPPROTO_IPV6, (join ? ADD_MEMBERSHIP : DRP_MEMBERSHIP), | ||
(char *) &mname6, sizeof (mname6)) < 0) { | ||
res = setsockopt(fd, IPPROTO_IPV6, (join ? ADD_MEMBERSHIP : DRP_MEMBERSHIP), | ||
(char *) &mname6, sizeof (mname6)); | ||
|
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.
Seems to be an extraneous space after sizeof here.
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.
A general question. Is "APPLE" the preferred macro name or MACOSX? Not a big deal but MACOSX looks slightly more common. [Seems github has removed the underscores from APPLE]
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.
thanks ... I'll attend to the spacing
I used APPLE as it was already in place for a change to set socket buffer size
… failed with "SocketException: Cannot allocate memory" remove #ifdef __APPLE__ from int res; declaration, remove space and fix indentation (as per comments from CH and M3)
/integrate |
Going to push as commit d8a0582.
Your commit was automatically rebased without conflicts. |
JDK-8265369 [macos-aarch64] java/net/MulticastSocket/Promiscuous.java failed with "SocketException: Cannot allocate memory"
The test java/net/MulticastSocket/Promiscuous.java has been observed to fail on a regular basis on macosx-aarch.
This is typically under heavy test load on a test machine. Analysis of the problem have
shown that the setsockopt for joining a multicast group will intermittently fail with ENOMEM.
While analysis of test environment shows significant memory usage and some memory pressure, it is
not excessive and as such it is deemed transition or temporary condition, such that a retry of the
setsockopt system call, has been seen to mitigate the issue. This adds to the stability of the
Promiscuous.java test and reduces test failure noise.
The proposed fix is in open/src/java.base/unix/native/libnet/PlainDatagramSocketImpl.c
in the mcast_join_leave function. That is, if setsockopt to join an mcast group fails, and the errno == ENOMEM,
then re-invoke the setsockopt system call for joining a mcast group.
The change has been applied as a conditional compilation.
Additionally this change result in the Promiscuous.java test being removed from the
ProblemList.txt.
Please oblige and review the changes for a fix of the issue JDK-8265369
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk17 pull/44/head:pull/44
$ git checkout pull/44
Update a local copy of the PR:
$ git checkout pull/44
$ git pull https://git.openjdk.java.net/jdk17 pull/44/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 44
View PR using the GUI difftool:
$ git pr show -t 44
Using diff file
Download this PR as a diff file:
https://git.openjdk.java.net/jdk17/pull/44.diff