JDK-8204614 : VM crash when generating ClassCastException in C1 compiled code
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 11
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • OS: linux
  • CPU: aarch64
  • Submitted: 2018-06-08
  • Updated: 2018-06-12
  • Resolved: 2018-06-12
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 11
11Fixed
Related Reports
Duplicate :  
Description
Graal has a bug in rev. 079591ab18a5694a8ba5cf630ed4f76d3442fe21, where a ClassCastException is thrown in method org.graalvm.compiler.lir.aarch64.AArch64AtomicMove.AtomicReadAndAdd.emitCode. But instead of throwing the exception, the entire VM crashes.

#
# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0x0000ffff80213698, pid=26434, tid=26507
#
# JRE version: OpenJDK Runtime Environment (11.0) (build 11-labs+0-SNAPSHOT-20180607-130447)
# Java VM: OpenJDK 64-Bit Server VM (11-labs+0-SNAPSHOT-20180607-130447, mixed mode, tiered, jvmci, jvmci compiler, compressed oops, g1 gc, linux-aarch64)
# Problematic frame:
# V  [libjvm.so+0x7f0698]  Klass::class_loader_and_module_name() const+0x138
#
# No core dump will be written. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
#
# An error report file with more information is saved as:
# /home/sanzinger/graal/graal/compiler/hs_err_pid26434.log


Steps to reproduce on AArch64 with latest OpenJDK 11:

git clone https://github.com/oracle/graal.git
cd graal
git checkout 079591ab18a5694a8ba5cf630ed4f76d3442fe21
mx build
mx vm -XX:+UseJVMCICompiler -XX:+BootstrapJVMCI


It seems that the C1 generated code for class jdk/vm/ci/code/ValueUtil.asRegisterValue is incorrect and leads to the VM crash.

Following command throws the exception properly without a VM crash by excluding ValueUtil.asRegister from compilation:

mx vm -XX:+UseJVMCICompiler -XX:+BootstrapJVMCI -XX:CompileCommand=exclude,jdk/vm/ci/code/ValueUtil.asRegisterValue

CompileCommand: exclude jdk/vm/ci/code/ValueUtil.asRegisterValue
Bootstrapping JVMCI....................Thread[JVMCI CompilerThread17,9,system]: Compilation of org.graalvm.compiler.nodes.StructuredGraph.<init>(String, Resol
vedJavaMethod, int, Assumptions, SpeculationLog, boolean, Graph$SourcePositionTracking, CompilationIdentifier, OptionValues, DebugContext, Cancellable, NodeSo
urcePosition) failed: org.graalvm.compiler.debug.GraalError: java.lang.ClassCastException: jdk.internal.vm.compiler/org.graalvm.compiler.lir.ConstantValue can
not be cast to jdk.internal.vm.ci/jdk.vm.ci.code.RegisterValue
        at lir instruction: B358@3698 org.graalvm.compiler.lir.aarch64.AArch64AtomicMove$AtomicReadAndAddOp r0|QWORD = ATOMIC_READ_AND_ADD (~addressValue: r1|
QWORD[.], ~deltaValue: long[1|0x1]) {scratchValue1: r2|QWORD, scratchValue2: r3|QWORD} accessKind: QWORD
[B0, B2, [..], B406, B197]
        at jdk.internal.vm.compiler/org.graalvm.compiler.lir.asm.CompilationResultBuilder.emitOp(CompilationResultBuilder.java:542)
        at jdk.internal.vm.compiler/org.graalvm.compiler.lir.asm.CompilationResultBuilder.emitBlock(CompilationResultBuilder.java:522)
[...]

[~aph] can you help out here?
Comments
Tested on latest openjdk build. The exeption is thrown without VM crash. Fixed.
12-06-2018

I'll test it later today.
12-06-2018

JDK-8204606 was submitted by Andrew, it should be possible to check whether this issue can be resolved.
12-06-2018

I believe this is a duplicate of JDK-8204606.
11-06-2018