JDK-8059238 : StringTable: assert(number_of_entries_counted==number_of_entries_expected) failed: should be equal
  • Type: Bug
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 8
  • Priority: P4
  • Status: Closed
  • Resolution: Not an Issue
  • Submitted: 2014-09-26
  • Updated: 2015-03-30
  • Resolved: 2015-03-30
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 9
9Resolved
Related Reports
Relates :  
Description
StringTable: assert(number_of_entries_counted==number_of_entries_expected) failed: should be equal

While working on JDK-6610955 I noticed an assert triggering in my code, but the assert itself (added to StringTable::verify()) still triggers even with clean JDK8 repo. This results in the following hotspot/test failures:


Execution failed: `main' threw exception: java.lang.RuntimeException: Expected to get exit value of [0]

gc/g1/TestDeferredRSUpdate.java: Ensure that running with -XX:-G1DeferredRSUpdate does not crash the VM
gc/g1/TestGCLogMessages.java: Ensure that the PrintGCDetails output for a minor GC with G1 includes the expected necessary messages.


Here is the spewage from TestDeferredRSUpdate test:


>>>>>>      OH, oh
>>>>>>      number_of_entries_counted: 758
>>>>>>      number_of_entries_expected: 759


# To suppress the following error report, specify this argument
# after -XX: or in .hotspotrc:  SuppressErrorAt=/symbolTable.cpp:939
#
# A fatal error has been detected by the Java Runtime Environment:
#
#  Internal Error (/Users/gerard/Desktop/jdk8_before/hotspot/src/share/vm/classfile/symbolTable.cpp:939), pid=75670, tid=19715
#  assert(number_of_entries_counted==number_of_entries_expected) failed: should be equal
#
# JRE version: Java(TM) SE Runtime Environment (8.0) (build 1.8.0-internal-fastdebug-gerard_2014_09_09_22_07-b00)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (1.8-b0-internal-fastdebug mixed mode bsd-amd64 compressed oops)
# Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
#
# An error report file with more information is saved as:
# /Users/gerard/Desktop/jdk8_after_2/hotspot/JTwork/scratch/hs_err_pid75670.log
#
# If you would like to submit a bug report, please visit:
#   http://bugreport.sun.com/bugreport/crash.jsp
#


Here is the modified StringTable::verify() in symbolTable.cpp file (in JDK9 the tables are split into separate files):

// This verification is part of Universe::verify() and needs to be quick.
// See StringTable::verify_and_compare() below for exhaustive verification.
void StringTable::verify() {
  int number_of_entries_counted = 0;
  for (int i = 0; i < the_table()->table_size(); ++i) {
    HashtableEntry<oop, mtSymbol>* p = the_table()->bucket(i);
    for ( ; p != NULL; p = p->next()) {
      oop s = p->literal();
      guarantee(s != NULL, "interned string is NULL");
      unsigned int h = java_lang_String::hash_string(s);
      guarantee(p->hash() == h, "broken hash in string table entry");
      guarantee(the_table()->hash_to_index(h) == i,
                "wrong index in string table");
      number_of_entries_counted++;
    }
  }
#ifdef ASSERT
  int number_of_entries_expected = the_table()->number_of_entries();
  if (number_of_entries_counted!=number_of_entries_expected) {
    tty->print("\n");
    tty->print("\n");
    tty->print(">>>>>>      OH, oh\n");
    tty->print(">>>>>>      number_of_entries_counted: %d\n", number_of_entries_counted);
    tty->print(">>>>>>      number_of_entries_expected: %d\n", number_of_entries_expected);
    tty->print("\n");
    tty->print("\n");
  }
  assert(number_of_entries_counted==number_of_entries_expected, "should be equal");
#endif // ASSERT
}

The way to run the test on Mac from within /Users/gerard/Desktop/jdk8/hotspot:

/Volumes/work/tests/jtreg/bin/jtreg -testjdk /tmp/jdk_build/jdk test/gc/g1 ; say "done testing"


Comments
The assert is likely not valid for StringTable (and SymbolTable), because they can be accessed concurrently. Closing as Not an issue
30-03-2015

Looks like StringTable::buckets_unlink_or_oops_do and SymbolTable::buckets_unlink needed their respective "MutexLocker mu(lock);" locks. Need to run tests to make sure that does not cause other regressions.
26-09-2014

SystemDictionary::verify() has such an assertion, but neither SymbolTable nor StringTable do.
26-09-2014