-
Notifications
You must be signed in to change notification settings - Fork 6.2k
8366495: Incorrect minimum memory size allocated in allocateNativeInternal() #27027
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 amitkumar! A progress list of the required criteria for merging this PR into |
@offamitkumar This change is no longer ready for integration - check the PR body for details. |
@offamitkumar 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
|
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 spotting this bug! It seems like a bug that I introduced, and so, thanks again!
Hello Amit, would it be possible to add a jtreg test for this? Do you know what was the code path or values for the |
Hi @jaikiran , I will spend some time over it, current jtreg tests are unable to detect it. This is information Aditi gave me regarding the failure in OpenJ9: |
I think it's OK (and understandable) if the jtreg test doesn't reproduce a JVM crash itself. What would be good, is to have the same API call(s) with those relevant values being invoked from the jtreg test. It may be that we already have a jtreg test which exercises those values and if we are able to identify such an existing test then it would be good to mention it here or in the JBS issue and we won't have to introduce a new one. |
I had a deeper look at this and this specific issue can happen only when the |
@@ -198,7 +198,7 @@ private static long allocateNativeInternal(long byteSize, long byteAlignment, Me | |||
} | |||
// Always allocate at least some memory so that zero-length segments have distinct | |||
// non-zero addresses. | |||
alignedSize = Math.max(1, alignedSize); | |||
alignedSize = Math.max(Long.BYTES, alignedSize); |
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 few lines above this code there's a comment which says:
// Align the allocation size up to a multiple of 8 so we can init the memory with longs
long alignedSize = init ? Utils.alignUp(byteSize, Long.BYTES) : byteSize;
Should we have a similar comment as well as a check for init
here? After all, we are increasing this size here because of init
initializing the allocated memory. So perhaps something like:
// Always allocate at least some memory so that zero-length segments have distinct
// non-zero addresses. If we are initializing the allocated memory, then use a minimum
// size of 8 because we init the memory with longs.
alignedSize = Math.max((init ? Long.BYTES : 1), alignedSize);
If you do use this newer proposed change, then please have it verified against the original reproducer.
Hi @jaikiran , |
Not being able to generate a JVM crash or a test failure from that test is understandable and OK. Such memory access issues aren't always reproducible in a deterministic manner. So yes, it's OK to not introduce a new test. |
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 new changes look good. Thanks for fixing this issue. Please update the title of the PR so we can integrate this one.
/reviewers 2 |
Originally Reported in OpenJ9, fix by @AditiS11 present here: ibmruntimes/openj9-openjdk-jdk25#32
These test failure were reported in OpenJ9 (x86), I can't reproduce on my system (s390x):
Here minimum-allocated size will be 1, which is incorrect because
initNativeMemory()
is going to write Long.Progress
Integration blocker
8366495
. Please make sure it exists and is accessible.Issue
8366495
.Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/27027/head:pull/27027
$ git checkout pull/27027
Update a local copy of the PR:
$ git checkout pull/27027
$ git pull https://git.openjdk.org/jdk.git pull/27027/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 27027
View PR using the GUI difftool:
$ git pr show -t 27027
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/27027.diff
Using Webrev
Link to Webrev Comment