# HG changeset patch # User iveresov # Date 1223959302 25200 # Node ID 078b8a0d8d7cb6966bbb29821be78ea4c250e048 # Parent 05366dad12cfbbc25db0e2f1d885b2f51c3818bc 6758633: G1: SEGV with GCOld on Linux Summary: Avoid growth of a GrowableArray backend of HeapRegionSeq. Reviewed-by: tonyp, jcoomes diff -r 05366dad12cf -r 078b8a0d8d7c src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp --- a/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp Thu Oct 09 12:06:22 2008 -0400 +++ b/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp Mon Oct 13 21:41:42 2008 -0700 @@ -1398,7 +1398,7 @@ _g1_storage.initialize(g1_rs, 0); _g1_committed = MemRegion((HeapWord*)_g1_storage.low(), (size_t) 0); _g1_max_committed = _g1_committed; - _hrs = new HeapRegionSeq(); + _hrs = new HeapRegionSeq(_expansion_regions); guarantee(_hrs != NULL, "Couldn't allocate HeapRegionSeq"); guarantee(_cur_alloc_region == NULL, "from constructor"); diff -r 05366dad12cf -r 078b8a0d8d7c src/share/vm/gc_implementation/g1/heapRegionSeq.cpp --- a/src/share/vm/gc_implementation/g1/heapRegionSeq.cpp Thu Oct 09 12:06:22 2008 -0400 +++ b/src/share/vm/gc_implementation/g1/heapRegionSeq.cpp Mon Oct 13 21:41:42 2008 -0700 @@ -37,7 +37,7 @@ return 0; } -HeapRegionSeq::HeapRegionSeq() : +HeapRegionSeq::HeapRegionSeq(const size_t max_size) : _alloc_search_start(0), // The line below is the worst bit of C++ hackery I've ever written // (Detlefs, 11/23). You should think of it as equivalent to @@ -50,7 +50,7 @@ _regions((ResourceObj::operator new (sizeof(GrowableArray), (void*)&_regions, ResourceObj::C_HEAP), - 100), + (int)max_size), true), _next_rr_candidate(0), _seq_bottom(NULL) @@ -167,6 +167,7 @@ // Public methods. void HeapRegionSeq::insert(HeapRegion* hr) { + assert(!_regions.is_full(), "Too many elements in HeapRegionSeq"); if (_regions.length() == 0 || _regions.top()->end() <= hr->bottom()) { hr->set_hrs_index(_regions.length()); diff -r 05366dad12cf -r 078b8a0d8d7c src/share/vm/gc_implementation/g1/heapRegionSeq.hpp --- a/src/share/vm/gc_implementation/g1/heapRegionSeq.hpp Thu Oct 09 12:06:22 2008 -0400 +++ b/src/share/vm/gc_implementation/g1/heapRegionSeq.hpp Mon Oct 13 21:41:42 2008 -0700 @@ -49,7 +49,7 @@ public: // Initializes "this" to the empty sequence of regions. - HeapRegionSeq(); + HeapRegionSeq(const size_t max_size); // Adds "hr" to "this" sequence. Requires "hr" not to overlap with // any region already in "this". (Will perform better if regions are