changeset 821:47ffceb239d0

6839599: JVM crash while profiling Tomcat and Liferay Summary: constantPoolOopDesc::copy_cpool_bytes() - do the brute-force search search through 'tbl' when SymbolTable::lookup_only() returns NULL Reviewed-by: kamg
author thurka
date Wed, 20 May 2009 09:36:53 +0200
parents c55be0c7bd32
children f1f3a2719a55
files src/share/vm/oops/constantPoolOop.cpp
diffstat 1 files changed, 22 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/vm/oops/constantPoolOop.cpp	Wed May 13 08:46:58 2009 -0700
+++ b/src/share/vm/oops/constantPoolOop.cpp	Wed May 20 09:36:53 2009 +0200
@@ -1181,7 +1181,28 @@
         unsigned int hash;
         char *str = string_at_noresolve(idx);
         symbolOop sym = SymbolTable::lookup_only(str, (int) strlen(str), hash);
-        idx1 = tbl->symbol_to_value(sym);
+        if (sym == NULL) {
+          // sym can be NULL if string refers to incorrectly encoded JVM_CONSTANT_Utf8
+          // this can happen with JVM TI; see CR 6839599 for more details
+          oop string = *(obj_at_addr(idx));
+          assert(java_lang_String::is_instance(string),"Not a String");
+          DBG(printf("Error #%03hd tag=%03hd\n", idx, tag));
+          idx1 = 0;
+          for (int j = 0; j < tbl->table_size() && idx1 == 0; j++) {
+            for (SymbolHashMapEntry* cur = tbl->bucket(j); cur != NULL; cur = cur->next()) {
+              int length;
+              sym = cur->symbol();
+              jchar* chars = sym->as_unicode(length);
+              if (java_lang_String::equals(string, chars, length)) {
+                idx1 = cur->value();
+                DBG(printf("Index found: %d\n",idx1));
+                break;
+              }
+            }
+          }
+        } else {
+          idx1 = tbl->symbol_to_value(sym);
+        }
         assert(idx1 != 0, "Have not found a hashtable entry");
         Bytes::put_Java_u2((address) (bytes+1), idx1);
         DBG(printf("JVM_CONSTANT_String: idx=#%03hd, %s", idx1, str));