JDK-7170053 : crash in C2 when using -XX:+CountCompiledCalls
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: hs23
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2012-05-18
  • Updated: 2014-06-10
  • Resolved: 2012-05-26
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 7 JDK 8 Other
7u40Fixed 8Fixed hs24Fixed
Related Reports
Duplicate :  

Krystal Mok wrote:

Hi all,

Could I get some reviews for this patch, please?


C2 may crash when compiling methods with -XX:+CountCompiledCalls turned on.
The cause is in Parse::count_compiled_calls(), where it made a TypeInstPtr
from a ciMethod:

const TypeInstPtr* addr_type = TypeInstPtr::make(method());

Since the klass of a ciMethod is a ciMethodKlass, which isn't a
ciInstanceKlass, an assertion is hit later in
Compile::flatten_alias_type(), where it's expecting a TypeInstPtr to have a

ciInstanceKlass *k = to->klass()->as_instance_klass();

An example of the crash is available here: https://gist.github.com/2710000
In the example, I started a Groovy shell with -XX:+CountCompiledCalls set,
and it crashed quickly when compiling java.lang.String.charAt().

The fix is to use TypeOopPtr::make_from_constant(method()) instead
of TypeInstPtr::make(method()).
I did check the hg history, and looks like it's been like this since
duke at 0.Wonder if there's any history behind this.

Note that this fix may have to be changed again when methodOopDesc's are
moved out of PermGen.


EVALUATION http://hg.openjdk.java.net/lambda/lambda/hotspot/rev/cdd249497b34

EVALUATION http://hg.openjdk.java.net/hsx/hotspot-comp/hotspot/rev/cdd249497b34