8019835: Strings interned in different threads equal but does not ==

Add -XX:+VerifyStringTableAtExit option and code to verify StringTable invariants.

Reviewed-by: rdurbin, sspitsyn, coleenp
This commit is contained in:
Daniel D. Daugherty 2013-09-18 07:02:10 -07:00
parent 876967ae1f
commit 41bce440a4
6 changed files with 218 additions and 0 deletions

View file

@ -544,6 +544,19 @@ void before_exit(JavaThread * thread) {
// it will run into trouble when system destroys static variables.
MemTracker::shutdown(MemTracker::NMT_normal);
if (VerifyStringTableAtExit) {
int fail_cnt = 0;
{
MutexLocker ml(StringTable_lock);
fail_cnt = StringTable::verify_and_compare_entries();
}
if (fail_cnt != 0) {
tty->print_cr("ERROR: fail_cnt=%d", fail_cnt);
guarantee(fail_cnt == 0, "unexpected StringTable verification failures");
}
}
#undef BEFORE_EXIT_NOT_RUN
#undef BEFORE_EXIT_RUNNING
#undef BEFORE_EXIT_DONE