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

Wed, 11 May 2011 15:47:12 -0700

author
ysr
date
Wed, 11 May 2011 15:47:12 -0700
changeset 2891
7d64aa23eb96
parent 2890
97b64f73103b
child 2892
30d3b13f1938

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

src/share/vm/gc_implementation/parNew/parCardTableModRefBS.cpp file | annotate | diff | comparison | revisions
src/share/vm/memory/blockOffsetTable.cpp file | annotate | diff | comparison | revisions
src/share/vm/memory/cardTableModRefBS.hpp file | annotate | diff | comparison | revisions
     1.1 --- a/src/share/vm/gc_implementation/parNew/parCardTableModRefBS.cpp	Tue May 10 12:26:10 2011 -0700
     1.2 +++ b/src/share/vm/gc_implementation/parNew/parCardTableModRefBS.cpp	Wed May 11 15:47:12 2011 -0700
     1.3 @@ -351,7 +351,7 @@
     1.4          // covers.
     1.5          const uintptr_t last_chunk_index_to_check = addr_to_chunk_index(last_block + last_block_size - 1)
     1.6                                                      - lowest_non_clean_base_chunk_index;
     1.7 -        DEBUG_ONLY(const uintptr_t last_chunk_index = addr_to_chunk_index(used.end())
     1.8 +        DEBUG_ONLY(const uintptr_t last_chunk_index = addr_to_chunk_index(used.last())
     1.9                                                        - lowest_non_clean_base_chunk_index;)
    1.10          assert(last_chunk_index_to_check <= last_chunk_index,
    1.11                 err_msg("Out of bounds: last_chunk_index_to_check " INTPTR_FORMAT
     2.1 --- a/src/share/vm/memory/blockOffsetTable.cpp	Tue May 10 12:26:10 2011 -0700
     2.2 +++ b/src/share/vm/memory/blockOffsetTable.cpp	Wed May 11 15:47:12 2011 -0700
     2.3 @@ -541,20 +541,33 @@
     2.4      // to go back by.
     2.5      size_t n_cards_back = entry_to_cards_back(offset);
     2.6      q -= (N_words * n_cards_back);
     2.7 -    assert(q >= _sp->bottom(), "Went below bottom!");
     2.8 +    assert(q >= _sp->bottom(),
     2.9 +           err_msg("q = " PTR_FORMAT " crossed below bottom = " PTR_FORMAT,
    2.10 +                   q, _sp->bottom()));
    2.11 +    assert(q < _sp->end(),
    2.12 +           err_msg("q = " PTR_FORMAT " crossed above end = " PTR_FORMAT,
    2.13 +                   q, _sp->end()));
    2.14      index -= n_cards_back;
    2.15      offset = _array->offset_array(index);
    2.16    }
    2.17    assert(offset < N_words, "offset too large");
    2.18    index--;
    2.19    q -= offset;
    2.20 +  assert(q >= _sp->bottom(),
    2.21 +         err_msg("q = " PTR_FORMAT " crossed below bottom = " PTR_FORMAT,
    2.22 +                 q, _sp->bottom()));
    2.23 +  assert(q < _sp->end(),
    2.24 +         err_msg("q = " PTR_FORMAT " crossed above end = " PTR_FORMAT,
    2.25 +                 q, _sp->end()));
    2.26    HeapWord* n = q;
    2.27  
    2.28    while (n <= addr) {
    2.29      debug_only(HeapWord* last = q);   // for debugging
    2.30      q = n;
    2.31      n += _sp->block_size(n);
    2.32 -    assert(n > q, err_msg("Looping at: " INTPTR_FORMAT, n));
    2.33 +    assert(n > q,
    2.34 +           err_msg("Looping at n = " PTR_FORMAT " with last = " PTR_FORMAT " _sp = [" PTR_FORMAT "," PTR_FORMAT ")",
    2.35 +                   n, last, _sp->bottom(), _sp->end()));
    2.36    }
    2.37    assert(q <= addr, err_msg("wrong order for current (" INTPTR_FORMAT ") <= arg (" INTPTR_FORMAT ")", q, addr));
    2.38    assert(addr <= n, err_msg("wrong order for arg (" INTPTR_FORMAT ") <= next (" INTPTR_FORMAT ")", addr, n));
     3.1 --- a/src/share/vm/memory/cardTableModRefBS.hpp	Tue May 10 12:26:10 2011 -0700
     3.2 +++ b/src/share/vm/memory/cardTableModRefBS.hpp	Wed May 11 15:47:12 2011 -0700
     3.3 @@ -150,7 +150,9 @@
     3.4    // Mapping from address to card marking array entry
     3.5    jbyte* byte_for(const void* p) const {
     3.6      assert(_whole_heap.contains(p),
     3.7 -           "out of bounds access to card marking array");
     3.8 +           err_msg("Attempt to access p = "PTR_FORMAT" out of bounds of "
     3.9 +                   " card marking array's _whole_heap = ["PTR_FORMAT","PTR_FORMAT")",
    3.10 +                   p, _whole_heap.start(), _whole_heap.end()));
    3.11      jbyte* result = &byte_map_base[uintptr_t(p) >> card_shift];
    3.12      assert(result >= _byte_map && result < _byte_map + _byte_map_size,
    3.13             "out of bounds accessor for card marking array");
    3.14 @@ -451,14 +453,18 @@
    3.15      size_t delta = pointer_delta(p, byte_map_base, sizeof(jbyte));
    3.16      HeapWord* result = (HeapWord*) (delta << card_shift);
    3.17      assert(_whole_heap.contains(result),
    3.18 -           "out of bounds accessor from card marking array");
    3.19 +           err_msg("Returning result = "PTR_FORMAT" out of bounds of "
    3.20 +                   " card marking array's _whole_heap = ["PTR_FORMAT","PTR_FORMAT")",
    3.21 +                   result, _whole_heap.start(), _whole_heap.end()));
    3.22      return result;
    3.23    }
    3.24  
    3.25    // Mapping from address to card marking array index.
    3.26    size_t index_for(void* p) {
    3.27      assert(_whole_heap.contains(p),
    3.28 -           "out of bounds access to card marking array");
    3.29 +           err_msg("Attempt to access p = "PTR_FORMAT" out of bounds of "
    3.30 +                   " card marking array's _whole_heap = ["PTR_FORMAT","PTR_FORMAT")",
    3.31 +                   p, _whole_heap.start(), _whole_heap.end()));
    3.32      return byte_for(p) - _byte_map;
    3.33    }
    3.34  

mercurial