JDK-6865583 : Verbose CIPrintMethodCodes asserts when ldc an empty String
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: hs16
  • Priority: P5
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2009-07-28
  • Updated: 2011-03-08
  • Resolved: 2011-03-08
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 6 JDK 7 Other
6u21Fixed 7Fixed hs17Fixed
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
EVALUATION http://hg.openjdk.java.net/jdk7/hotspot-comp/hotspot/rev/489a4f8dcd0f
27-08-2009

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().
28-07-2009

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); }
28-07-2009