JDK-6910183 : CMS: assert(_index < capacity(),"_index out of bounds")
  • Type: Bug
  • Component: hotspot
  • Sub-Component: gc
  • Affected Version: hs17,hs19
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic,x86
  • Submitted: 2009-12-14
  • Updated: 2012-02-01
  • Resolved: 2011-04-23
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 6 JDK 7 Other
6u25Fixed 7Fixed hs20Fixed
Related Reports
Relates :  
Description
The test in attachment (same for CR6910182) could cause CMS crash with assertion:

# after -XX: or in .hotspotrc:  SuppressErrorAt=/concurrentMarkSweepGeneration.hpp:269
#
# A fatal error has been detected by the Java Runtime Environment:
#
#  Internal Error (/BUILD_AREA/jdk7/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.hpp:269), pid=1557, tid=2867215248
#  Error: assert(_index < capacity(),"_index out of bounds")
#
# JRE version: 7.0-b77
# Java VM: Java HotSpot(TM) Server VM (17.0-b05-fastdebug mixed mode linux-x86 )
# An error report file with more information is saved as:
# /home/lm153972/ws/cms/file/hs_err_pid1557.log
#
# If you would like to submit a bug report, please visit:
#   http://java.sun.com/webapps/bugreport/crash.jsp
#
Current thread is 2867215248
Dumping core ...


I appeares on the 32bit linux:
java -version:
java version "1.7.0-ea-fastdebug"
Java(TM) SE Runtime Environment (build 1.7.0-ea-fastdebug-b77)
Java HotSpot(TM) Server VM (build 17.0-b05-fastdebug, mixed mode)

I run it with reduced YoungGen (to provoke CMS) like below: 
/net/vmsqe.russia/export/jdk/7/build/latest/linux-i586/fastdebug/bin/java -server -Xmn200K  -XX:+PrintGCDetails  -XX:+UseConcMarkSweepGC crash_concurrentMarkSweepGeneration_5362  | grep -v ParNew

It does not crash each time sometimes.
gc.gctests.ReferencesGC.ReferencesGC

Comments
EVALUATION http://hg.openjdk.java.net/jdk7/hotspot-gc/hotspot/rev/bba76f745fe6
24-08-2010

SUGGESTED FIX --- a/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.hpp +++ b/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.hpp @@ -252,12 +252,13 @@ class ChunkArray: public CHeapObj { class ChunkArray: public CHeapObj { size_t _index; size_t _capacity; + uint _overflows; HeapWord** _array; // storage for array public: - ChunkArray() : _index(0), _capacity(0), _array(NULL) {} + ChunkArray() : _index(0), _capacity(0), _overflows(0), _array(NULL) {} ChunkArray(HeapWord** a, size_t c): - _index(0), _capacity(c), _array(a) {} + _index(0), _capacity(c), _overflows(0), _array(a) {} HeapWord** array() { return _array; } void set_array(HeapWord** a) { _array = a; } @@ -266,7 +267,9 @@ class ChunkArray: public CHeapObj { void set_capacity(size_t c) { _capacity = c; } size_t end() { - assert(_index < capacity(), "_index out of bounds"); + assert(_index <= capacity(), + err_msg("_index (" SIZE_FORMAT ") > _capacity (" SIZE_FORMAT "): out of bounds", + _index, _capacity)); return _index; } // exclusive @@ -277,12 +280,22 @@ class ChunkArray: public CHeapObj { void reset() { _index = 0; + if (_overflows > 0 && PrintCMSStatistics > 0) { + warning("CMS: ChunkArray[" SIZE_FORMAT "] overflowed %d times", + _capacity, _overflows); + } + _overflows = 0; } void record_sample(HeapWord* p, size_t sz) { // For now we do not do anything with the size if (_index < _capacity) { _array[_index++] = p; + } else { + ++_overflows; + assert(_index == _capacity, + err_msg("_index (" SIZE_FORMAT ") > _capacity (" SIZE_FORMAT "): out of bounds at overflow#%d", + _index, _capacity, _overflows)); } } };
23-08-2010

EVALUATION An assert that was a tad too strong (off-by-one). Benign for product builds.
23-08-2010