-
Notifications
You must be signed in to change notification settings - Fork 6.1k
8360941: [ubsan] MemRegion::end() shows runtime error: applying non-zero offset 8388608 to null pointer #26216
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 mbaesken! A progress list of the required criteria for merging this PR into |
@MBaesken This change is no longer ready for integration - check the PR body for details. |
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.
Looks awful to me. But anyway - approved.
This is a perfect example where we destroy the clean look of hotspot code to accommodate odd usage. Wouldn't it be better to code the ugly stuff in the test?
I adjusted the test and took 'some other address than null' . And removed the cast from the header. |
Taking 'some other address' than nullptr / 0 as suggested just fails (I worked yesterday with opt build where no failure was seen).
|
@tschatzl , maybe you have a good suggestion for an address ? |
It needs to be at least page-aligned. I'm not finding any other alignment requirement just now, but there might So The other likely alignment possibility is I still think allocating the space might be safer. So os::malloc space for one more region than the test calls for, and |
@@ -44,7 +44,11 @@ TEST_OTHER_VM(G1FreeRegionList, length) { | |||
|
|||
// Create a fake heap. It does not need to be valid, as the G1HeapRegion constructor | |||
// does not access it. | |||
MemRegion heap(nullptr, num_regions_in_test * G1HeapRegion::GrainWords); | |||
int val = 1; | |||
HeapWord* ptr = reinterpret_cast<HeapWord*>(&val); |
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 initial value for val
doesn't matter, since we're using its address rather than value.
And the cast could be removed by changing the type of val
, leading to something like this:
HeapWord val{};
HeapWord* ptr = align_up(&val, os::vm_page_size());
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 adjusted the coding .
Hi Kim, should I add you as contributor ? |
HeapWord* ptr = align_up(&val, os::vm_page_size()); | ||
|
||
MemRegion heap(ptr, num_regions_in_test * G1HeapRegion::GrainWords); |
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 would not do it this way. The test should not write into the region, but if someone does mess up and does it, you get weird crashes. Possibly in other threads, because MemRegion is larger than your stack, and your stack may border on other stacks. Easier to just crash right on accessing uncommitted memory:
HeapWord* ptr = align_up(&val, os::vm_page_size()); | |
MemRegion heap(ptr, num_regions_in_test * G1HeapRegion::GrainWords); | |
const size_t szw = num_regions_in_test * G1HeapRegion::GrainWords; | |
const size_t sz = szw * BytePerWord; | |
char* addr = os::reserve_memory(sz, mtTest); | |
MemRegion heap((HeapWord*)ptr, szw); |
and then after the test release it: os::release_memory(addr, szw);
When running HS test
gtest/GTestWrapper.java
with ubsan-enabled binaries on macOS aarch64, the following error is reported (did not see this so far on Linux but there we use gcc and it seems the gcc/ubsan checks are a bit more limited).
test/hotspot/gtest/gc/g1/test_freeRegionList.cpp:37: Failure
Death test: child_G1FreeRegionList_length_()
Result: died but not with expected exit code:
Terminated by signal 6 (core dumped)
Actual msg:
Seems the test_freeRegionList.cpp uses a special MemRegion starting at nullptr ; but this causes a bit of trouble when adding to start == nullptr .
So far I see this issue just in the gtest, seems other MemRegion objects do not start at nullptr .
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/26216/head:pull/26216
$ git checkout pull/26216
Update a local copy of the PR:
$ git checkout pull/26216
$ git pull https://git.openjdk.org/jdk.git pull/26216/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 26216
View PR using the GUI difftool:
$ git pr show -t 26216
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/26216.diff
Using Webrev
Link to Webrev Comment