8157097: OptionsValidation/TestOptionsWithRanges.java crashes at CompactHashtableWriter::add during StringTable::copy_shared_string
authorrehn
Mon, 23 May 2016 09:57:17 +0200
changeset 38647 e17e25c51396
parent 38646 49e5e88613bf
child 38648 4e1ba08a4006
child 38651 c86a9e9079fb
child 38653 503088078afa
8157097: OptionsValidation/TestOptionsWithRanges.java crashes at CompactHashtableWriter::add during StringTable::copy_shared_string Reviewed-by: dholmes, jiangli
hotspot/src/share/vm/classfile/compactHashtable.cpp
hotspot/src/share/vm/classfile/stringTable.cpp
--- a/hotspot/src/share/vm/classfile/compactHashtable.cpp	Mon May 23 08:02:04 2016 +0200
+++ b/hotspot/src/share/vm/classfile/compactHashtable.cpp	Mon May 23 09:57:17 2016 +0200
@@ -38,6 +38,7 @@
 CompactHashtableWriter::CompactHashtableWriter(int num_buckets,
                                                CompactHashtableStats* stats) {
   assert(DumpSharedSpaces, "dump-time only");
+  assert(num_buckets > 0, "no buckets");
   _num_buckets = num_buckets;
   _num_entries = 0;
   _buckets = NEW_C_HEAP_ARRAY(GrowableArray<Entry>*, _num_buckets, mtSymbol);
--- a/hotspot/src/share/vm/classfile/stringTable.cpp	Mon May 23 08:02:04 2016 +0200
+++ b/hotspot/src/share/vm/classfile/stringTable.cpp	Mon May 23 09:57:17 2016 +0200
@@ -740,7 +740,8 @@
     } else {
       int num_buckets = the_table()->number_of_entries() /
                              SharedSymbolTableBucketSize;
-      CompactStringTableWriter writer(num_buckets,
+      // calculation of num_buckets can result in zero buckets, we need at least one
+      CompactStringTableWriter writer(num_buckets > 1 ? num_buckets : 1,
                                       &MetaspaceShared::stats()->string);
 
       // Copy the interned strings into the "string space" within the java heap