United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-6910183 CMS: assert(_index < capacity(),"_index out of bounds")
JDK-6910183 : CMS: assert(_index < capacity(),"_index out of bounds")

Details
Type:
Bug
Submit Date:
2009-12-14
Status:
Closed
Updated Date:
2012-02-01
Project Name:
JDK
Resolved Date:
2011-04-23
Component:
hotspot
OS:
generic
Sub-Component:
gc
CPU:
x86,generic
Priority:
P4
Resolution:
Fixed
Affected Versions:
hs17,hs19
Fixed Versions:
hs20 (b01)

Related Reports
Backport:
Backport:
Relates:

Sub Tasks

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
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));
     }
   }
 };
                                     
2010-08-23
EVALUATION

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

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



Hardware and Software, Engineered to Work Together