8154743: Internal Error: psParallelCompact.hpp assert(addr >= _region_start) failed: bad addr
Reviewed-by: tschatzl, kbarrett
--- a/hotspot/src/share/vm/gc/parallel/psParallelCompact.cpp Tue Apr 26 23:29:51 2016 +0530
+++ b/hotspot/src/share/vm/gc/parallel/psParallelCompact.cpp Tue Apr 26 09:19:19 2016 -0700
@@ -249,7 +249,7 @@
const size_t last = summary_data.addr_to_region_idx(end_addr);
HeapWord* pdest = 0;
- while (i <= last) {
+ while (i < last) {
ParallelCompactData::RegionData* c = summary_data.region(i);
if (c->data_size() != 0 || c->destination() != pdest) {
print_generic_summary_region(i, c);
@@ -377,6 +377,33 @@
print_generic_summary_data(summary_data, space->bottom(), space->top());
} while (++id < PSParallelCompact::last_space_id);
}
+
+void ParallelCompact_test() {
+ if (!UseParallelGC) {
+ return;
+ }
+ // Check that print_generic_summary_data() does not print the
+ // end region by placing a bad value in the destination of the
+ // end region. The end region should not be printed because it
+ // corresponds to the space after the end of the heap.
+ ParallelScavengeHeap* heap = ParallelScavengeHeap::heap();
+ ParCompactionManager* const vmthread_cm =
+ ParCompactionManager::manager_array(ParallelGCThreads);
+ HeapWord* begin_heap =
+ (HeapWord*) heap->old_gen()->virtual_space()->low_boundary();
+ HeapWord* end_heap =
+ (HeapWord*) heap->young_gen()->virtual_space()->high_boundary();
+
+ size_t end_index =
+ PSParallelCompact::summary_data().addr_to_region_idx(end_heap);
+ ParallelCompactData::RegionData* c = PSParallelCompact::summary_data().region(end_index);
+
+ // Initialize the end region with a bad destination.
+ c->set_destination(begin_heap - 1);
+
+ print_generic_summary_data(PSParallelCompact::summary_data(),
+ begin_heap, end_heap);
+}
#endif // #ifndef PRODUCT
#ifdef ASSERT
--- a/hotspot/src/share/vm/gc/parallel/psParallelCompact.hpp Tue Apr 26 23:29:51 2016 +0530
+++ b/hotspot/src/share/vm/gc/parallel/psParallelCompact.hpp Tue Apr 26 09:19:19 2016 -0700
@@ -631,8 +631,8 @@
inline size_t
ParallelCompactData::addr_to_region_idx(const HeapWord* addr) const
{
- assert(addr >= _region_start, "bad addr");
- assert(addr <= _region_end, "bad addr");
+ assert(addr >= _region_start, "bad addr " PTR_FORMAT " _region_start " PTR_FORMAT, p2i(addr), p2i(_region_start));
+ assert(addr <= _region_end, "bad addr " PTR_FORMAT " _region_end " PTR_FORMAT, p2i(addr), p2i(_region_end));
return pointer_delta(addr, _region_start) >> Log2RegionSize;
}
--- a/hotspot/src/share/vm/utilities/internalVMTests.cpp Tue Apr 26 23:29:51 2016 +0530
+++ b/hotspot/src/share/vm/utilities/internalVMTests.cpp Tue Apr 26 09:19:19 2016 -0700
@@ -98,6 +98,7 @@
run_unit_test(test_memset_with_concurrent_readers);
run_unit_test(TestPredictions_test);
run_unit_test(WorkerDataArray_test);
+ run_unit_test(ParallelCompact_test);
#endif
tty->print_cr("All internal VM tests passed");
}