Skip to content
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

8264908: Investigate adding BOT range check in G1BlockOffsetTablePart::block_at_or_preceding #4775

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -115,9 +115,8 @@ inline HeapWord* G1BlockOffsetTablePart::block_at_or_preceding(const void* addr)
"Object crossed region boundary, found offset %u instead of 0",
(uint) _bot->offset_array(_bot->index_for(_hr->bottom())));
size_t index = _bot->index_for(addr);
// We must make sure that the offset table entry we use is valid. If
// "addr" is past the end, start at the last valid index.
index = MIN2(index, _next_offset_index - 1);
// We must make sure that the offset table entry we use is valid.
assert(index < _next_offset_index, "Precondition");
Copy link
Contributor

@tschatzl tschatzl Jul 14, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel a bit uneasy that the caller (block_start) allows more than the callee (values < _hr->end()), but this is probably the change that is supposed to be coming?
Looks good, but I would have preferred the original change or the upcoming change with some asserts included.

Copy link
Member Author

@walulyai walulyai Jul 14, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can add the deferred change, instead of splitting it off into a separate PR.

Copy link
Member

@albertnetymk albertnetymk Jul 14, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the caller (block_start) allows more than the callee (values < _hr->end())

That path should never be taken, so I am not worried about. I suggested putting that in another PR since those assertions are not obvious from the current ticket title. Anyway, this is subjective.

Copy link
Contributor

@tschatzl tschatzl Jul 14, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@albertnetymk : I know. Still it seems something is missing to me, but that's subjective. Let's just defer it.


HeapWord* q = _bot->address_for_index(index);

@@ -734,61 +734,6 @@ void HeapRegion::verify(VerifyOption vo,
return;
}

HeapWord* the_end = end();
// Do some extra BOT consistency checking for addresses in the
// range [top, end). BOT look-ups in this range should yield
// top. No point in doing that if top == end (there's nothing there).
if (p < the_end) {
// Look up top
HeapWord* addr_1 = p;
HeapWord* b_start_1 = block_start_const(addr_1);
if (b_start_1 != p) {
log_error(gc, verify)("BOT look up for top: " PTR_FORMAT " "
" yielded " PTR_FORMAT ", expecting " PTR_FORMAT,
p2i(addr_1), p2i(b_start_1), p2i(p));
*failures = true;
return;
}

// Look up top + 1
HeapWord* addr_2 = p + 1;
if (addr_2 < the_end) {
HeapWord* b_start_2 = block_start_const(addr_2);
if (b_start_2 != p) {
log_error(gc, verify)("BOT look up for top + 1: " PTR_FORMAT " "
" yielded " PTR_FORMAT ", expecting " PTR_FORMAT,
p2i(addr_2), p2i(b_start_2), p2i(p));
*failures = true;
return;
}
}

// Look up an address between top and end
size_t diff = pointer_delta(the_end, p) / 2;
HeapWord* addr_3 = p + diff;
if (addr_3 < the_end) {
HeapWord* b_start_3 = block_start_const(addr_3);
if (b_start_3 != p) {
log_error(gc, verify)("BOT look up for top + diff: " PTR_FORMAT " "
" yielded " PTR_FORMAT ", expecting " PTR_FORMAT,
p2i(addr_3), p2i(b_start_3), p2i(p));
*failures = true;
return;
}
}

// Look up end - 1
HeapWord* addr_4 = the_end - 1;
HeapWord* b_start_4 = block_start_const(addr_4);
if (b_start_4 != p) {
log_error(gc, verify)("BOT look up for end - 1: " PTR_FORMAT " "
" yielded " PTR_FORMAT ", expecting " PTR_FORMAT,
p2i(addr_4), p2i(b_start_4), p2i(p));
*failures = true;
return;
}
}

verify_strong_code_roots(vo, failures);
}