提交 851e9dc2 编写于 作者: Y ysr

7043891: CMS: assert(_whole_heap.contains(p)) failed: out of bounds access to card marking array

Summary: Fixed assertion checking code that was attempting to translate addresses past end of space for card-table slot. Also elaborated some assertion checking messages.
Reviewed-by: iveresov, jmasa, tonyp
上级 62966473
...@@ -351,7 +351,7 @@ process_chunk_boundaries(Space* sp, ...@@ -351,7 +351,7 @@ process_chunk_boundaries(Space* sp,
// covers. // covers.
const uintptr_t last_chunk_index_to_check = addr_to_chunk_index(last_block + last_block_size - 1) const uintptr_t last_chunk_index_to_check = addr_to_chunk_index(last_block + last_block_size - 1)
- lowest_non_clean_base_chunk_index; - lowest_non_clean_base_chunk_index;
DEBUG_ONLY(const uintptr_t last_chunk_index = addr_to_chunk_index(used.end()) DEBUG_ONLY(const uintptr_t last_chunk_index = addr_to_chunk_index(used.last())
- lowest_non_clean_base_chunk_index;) - lowest_non_clean_base_chunk_index;)
assert(last_chunk_index_to_check <= last_chunk_index, assert(last_chunk_index_to_check <= last_chunk_index,
err_msg("Out of bounds: last_chunk_index_to_check " INTPTR_FORMAT err_msg("Out of bounds: last_chunk_index_to_check " INTPTR_FORMAT
......
...@@ -541,20 +541,33 @@ HeapWord* BlockOffsetArrayNonContigSpace::block_start_unsafe( ...@@ -541,20 +541,33 @@ HeapWord* BlockOffsetArrayNonContigSpace::block_start_unsafe(
// to go back by. // to go back by.
size_t n_cards_back = entry_to_cards_back(offset); size_t n_cards_back = entry_to_cards_back(offset);
q -= (N_words * n_cards_back); q -= (N_words * n_cards_back);
assert(q >= _sp->bottom(), "Went below bottom!"); assert(q >= _sp->bottom(),
err_msg("q = " PTR_FORMAT " crossed below bottom = " PTR_FORMAT,
q, _sp->bottom()));
assert(q < _sp->end(),
err_msg("q = " PTR_FORMAT " crossed above end = " PTR_FORMAT,
q, _sp->end()));
index -= n_cards_back; index -= n_cards_back;
offset = _array->offset_array(index); offset = _array->offset_array(index);
} }
assert(offset < N_words, "offset too large"); assert(offset < N_words, "offset too large");
index--; index--;
q -= offset; q -= offset;
assert(q >= _sp->bottom(),
err_msg("q = " PTR_FORMAT " crossed below bottom = " PTR_FORMAT,
q, _sp->bottom()));
assert(q < _sp->end(),
err_msg("q = " PTR_FORMAT " crossed above end = " PTR_FORMAT,
q, _sp->end()));
HeapWord* n = q; HeapWord* n = q;
while (n <= addr) { while (n <= addr) {
debug_only(HeapWord* last = q); // for debugging debug_only(HeapWord* last = q); // for debugging
q = n; q = n;
n += _sp->block_size(n); n += _sp->block_size(n);
assert(n > q, err_msg("Looping at: " INTPTR_FORMAT, n)); assert(n > q,
err_msg("Looping at n = " PTR_FORMAT " with last = " PTR_FORMAT " _sp = [" PTR_FORMAT "," PTR_FORMAT ")",
n, last, _sp->bottom(), _sp->end()));
} }
assert(q <= addr, err_msg("wrong order for current (" INTPTR_FORMAT ") <= arg (" INTPTR_FORMAT ")", q, addr)); assert(q <= addr, err_msg("wrong order for current (" INTPTR_FORMAT ") <= arg (" INTPTR_FORMAT ")", q, addr));
assert(addr <= n, err_msg("wrong order for arg (" INTPTR_FORMAT ") <= next (" INTPTR_FORMAT ")", addr, n)); assert(addr <= n, err_msg("wrong order for arg (" INTPTR_FORMAT ") <= next (" INTPTR_FORMAT ")", addr, n));
......
...@@ -150,7 +150,9 @@ class CardTableModRefBS: public ModRefBarrierSet { ...@@ -150,7 +150,9 @@ class CardTableModRefBS: public ModRefBarrierSet {
// Mapping from address to card marking array entry // Mapping from address to card marking array entry
jbyte* byte_for(const void* p) const { jbyte* byte_for(const void* p) const {
assert(_whole_heap.contains(p), assert(_whole_heap.contains(p),
"out of bounds access to card marking array"); err_msg("Attempt to access p = "PTR_FORMAT" out of bounds of "
" card marking array's _whole_heap = ["PTR_FORMAT","PTR_FORMAT")",
p, _whole_heap.start(), _whole_heap.end()));
jbyte* result = &byte_map_base[uintptr_t(p) >> card_shift]; jbyte* result = &byte_map_base[uintptr_t(p) >> card_shift];
assert(result >= _byte_map && result < _byte_map + _byte_map_size, assert(result >= _byte_map && result < _byte_map + _byte_map_size,
"out of bounds accessor for card marking array"); "out of bounds accessor for card marking array");
...@@ -451,14 +453,18 @@ public: ...@@ -451,14 +453,18 @@ public:
size_t delta = pointer_delta(p, byte_map_base, sizeof(jbyte)); size_t delta = pointer_delta(p, byte_map_base, sizeof(jbyte));
HeapWord* result = (HeapWord*) (delta << card_shift); HeapWord* result = (HeapWord*) (delta << card_shift);
assert(_whole_heap.contains(result), assert(_whole_heap.contains(result),
"out of bounds accessor from card marking array"); err_msg("Returning result = "PTR_FORMAT" out of bounds of "
" card marking array's _whole_heap = ["PTR_FORMAT","PTR_FORMAT")",
result, _whole_heap.start(), _whole_heap.end()));
return result; return result;
} }
// Mapping from address to card marking array index. // Mapping from address to card marking array index.
size_t index_for(void* p) { size_t index_for(void* p) {
assert(_whole_heap.contains(p), assert(_whole_heap.contains(p),
"out of bounds access to card marking array"); err_msg("Attempt to access p = "PTR_FORMAT" out of bounds of "
" card marking array's _whole_heap = ["PTR_FORMAT","PTR_FORMAT")",
p, _whole_heap.start(), _whole_heap.end()));
return byte_for(p) - _byte_map; return byte_for(p) - _byte_map;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册