-
Notifications
You must be signed in to change notification settings - Fork 5.8k
JDK-8261601: free memory in early return in Java_sun_nio_ch_sctp_SctpChannelImpl_receive0 #2540
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
Conversation
👋 Welcome back mbaesken! A progress list of the required criteria for merging this PR into |
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.
LGTM
@MBaesken 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 14 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 |
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.
LGTM
@MBaesken did you run the jdk_sctp tests? |
Hi, the com/sun/nio/sctp jtreg tests passed on linux x86_64. I'll put it into our internal build/test queue to see over night what it does on all the platforms. |
hi, any comments on this ? See SctpChannelImpl.c the malloc there is followed by a few early returns, where is the memory freed is these cases ? |
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 change looks fine. I don't know about handleSendFailed().
Yes, the error paths in handleSendFailed should be looked at. If NewDirectByteBuffer or recvmsg fails then addressP needs to be freed. Furthermore, if the NewObject fails and bufferObj != NULL then the memory for the direct buffer will need to be freed too (as JNI NewDirectByteBuffer does not setup a cleaner). |
/integrate |
@MBaesken Since your change was applied there have been 40 commits pushed to the
Your commit was automatically rebased without conflicts. Pushed as commit cdc874d. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
I see this has been integrated but the fix is incomplete. Are you planning to create a follow-on issue for the issues that I pointed out above? |
Hi Alan, thanks about your comment to my question about handleSendFailed . Best regards, Matthias |
There seems to be an early return in Java_sun_nio_ch_sctp_SctpChannelImpl_receive0 that misses freeing memory.
Sonar reports :
https://sonarcloud.io/project/issues?id=shipilev_jdk&languages=c&open=AXck8Cl0BBG2CXpcnjFu&resolved=false&severities=BLOCKER&types=BUG
Potential leak of memory pointed to by 'newBuf'
I adjusted the early return and added freeing memory .
Btw. while adjusting Java_sun_nio_ch_sctp_SctpChannelImpl_receive0 , I started to wonder what happens to the allocated memory in the same file in handleSendFailed ( if ((addressP = malloc(dataLength)) == NULL) ) in early return cases incl. the CHECK_NULL , is there some deallocation missing there too ?
Progress
Issue
Reviewers
Download
$ git fetch https://git.openjdk.java.net/jdk pull/2540/head:pull/2540
$ git checkout pull/2540