United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-6865583 Verbose CIPrintMethodCodes asserts when ldc an empty String
JDK-6865583 : Verbose CIPrintMethodCodes asserts when ldc an empty String

Details
Type:
Bug
Submit Date:
2009-07-28
Status:
Closed
Updated Date:
2011-03-08
Project Name:
JDK
Resolved Date:
2011-03-08
Component:
hotspot
OS:
generic
Sub-Component:
compiler
CPU:
generic
Priority:
P5
Resolution:
Fixed
Affected Versions:
hs16
Fixed Versions:
hs17 (b02)

Related Reports
Backport:
Backport:

Sub Tasks

Description
$ gamma -Xcomp -XX:+CIPrintMethodCodes -XX:+Verbose foo

asserts with:

#  Internal Error (/Users/twisti/mlvm/hotspot/src/share/vm/oops/typeArrayOop.hpp:54), pid=61271, tid=2954858496
#  Error: assert(is_within_bounds(which),"index out of bounds")

                                    

Comments
SUGGESTED FIX

diff --git a/src/share/vm/classfile/javaClasses.cpp b/src/share/vm/classfile/javaClasses.cpp
--- a/src/share/vm/classfile/javaClasses.cpp
+++ b/src/share/vm/classfile/javaClasses.cpp
@@ -252,7 +252,7 @@
   typeArrayOop value  = java_lang_String::value(obj);
   int          offset = java_lang_String::offset(obj);
   int          length = java_lang_String::length(obj);
-  jchar* base = value->char_at_addr(offset);
+  jchar* base = (length == 0) ? NULL : value->char_at_addr(offset);
   symbolOop sym = SymbolTable::lookup_unicode(base, length, THREAD);
   return symbolHandle(THREAD, sym);
 }
                                     
2009-07-28
EVALUATION

ldc seems to load an empty String and that leads to an assert on offset < length, which are both zero.  Fix as suggested.

Maybe this check should also be done in java_lang_String::as_symbol_or_null().
                                     
2009-07-28
EVALUATION

http://hg.openjdk.java.net/jdk7/hotspot-comp/hotspot/rev/489a4f8dcd0f
                                     
2009-08-27



Hardware and Software, Engineered to Work Together