JDK-8260279 : JVM crashes in LateInlineVirtualCallGenerator::do_late_inline when using -XX:+PrintOptoInlining
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: repo-panama
  • Priority: P3
  • Status: Open
  • Resolution: Unresolved
  • OS: generic
  • CPU: generic
  • Submitted: 2021-01-22
  • Updated: 2021-01-28
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.
Other
repo-panamaUnresolved
Related Reports
Relates :  
Relates :  
Relates :  
Description
#
# A fatal error has been detected by the Java Runtime Environment:
#
# Internal Error (/home/wanghuang/repo/panama-vector/src/hotspot/share/opto/compile.cpp:4220), pid=115478, tid=115678
# Error: ShouldNotReachHere()
#

# Problematic frame:
# V [libjvm.so+0x821324] Compile::print_inlining_move_to(CallGenerator*)+0xb0
#
# Core dump will be written. Default location: /home/wanghuang/bug/core.%e.115478.%t
#
# If you would like to submit a bug report, please visit:
# https://bugreport.java.com/bugreport/crash.jsp
#

--------------- S U M M A R Y ------------

Command Line: --add-modules=jdk.incubator.vector -Xcomp -XX:CompileCommand=compileonly,TestVectorPrintInline::* -XX:+PrintOptoInlining TestVectorPrintInline


--------------- T H R E A D ---------------

Current thread (0x0000ffff884f1f10): JavaThread "C2 CompilerThread0" daemon [_thread_in_native, id=115678, stack(0x0000ffff1ae00000,0x0000ffff1b000000)]


Current CompileTask:
C2: 2437 35 b 4 TestVectorPrintInline::main (20 bytes)

Stack: [0x0000ffff1ae00000,0x0000ffff1b000000], sp=0x0000ffff1affab30, free space=2026k
Native frames: (J=compiled Java code, A=aot compiled Java code, j=interpreted, Vv=VM code, C=native code)
V [libjvm.so+0x821324] Compile::print_inlining_move_to(CallGenerator*)+0xb0
V [libjvm.so+0x702134] LateInlineVirtualCallGenerator::do_late_inline()+0x634
V [libjvm.so+0x818fc8] Compile::inline_incrementally_one()+0x19c
V [libjvm.so+0x819488] Compile::inline_incrementally(PhaseIterGVN&)+0x194
V [libjvm.so+0x819ad8] Compile::Optimize()+0x174
V [libjvm.so+0x8140ec] Compile::Compile(ciEnv*, ciMethod*, int, bool, bool, bool, bool, DirectiveSet*)+0xebc
V [libjvm.so+0x6fe0ac] C2Compiler::compile_method(ciEnv*, ciMethod*, int, bool, DirectiveSet*)+0x10c
V [libjvm.so+0x82ffe0] CompileBroker::invoke_compiler_on_method(CompileTask*)+0x788
V [libjvm.so+0x82ed9c] CompileBroker::compiler_thread_loop()+0x378
V [libjvm.so+0x12d4934] compiler_thread_entry(JavaThread*, Thread*)+0x84
V [libjvm.so+0x12d07a4] JavaThread::thread_main_inner()+0x178
V [libjvm.so+0x12d0618] JavaThread::run()+0x19c
V [libjvm.so+0x12cc7b8] Thread::call_run()+0x19c
V [libjvm.so+0x1024670] thread_native_entry(Thread*)+0x1e4
C [libpthread.so.0+0x78bc] start_thread+0x19c

The reason is we use

```
virtual JVMState* generate(JVMState* jvms) {
    Compile* C = Compile::current();

    // Emit the CallDynamicJava and request separate projections so
    // that the late inlining logic can distinguish between fall
    // through and exceptional uses of the memory and io projections
    // as is done for allocations and macro expansion.
    JVMState* new_jvms = VirtualCallGenerator::generate(jvms);
    if (call_node() != NULL) {
      call_node()->set_generator(this);
    }
    return new_jvms;
  }
```

we use `VirtualCallGenerator::generate` which calls `print_inlining_update ` to update print_inlining list. However, `virtual _late_inline` case is missing. When we call `Compile::print_inlining_move_to` in `LateInlineVirtualCallGenerator::do_late_inline()`, we can not find a LateInlineVirtualCallGenerator in `_print_inlining_list`.

We can fix this bug with adding this line in the constructor of `LateInlineVirtualCallGenerator`:

+ virtual bool is_late_inline() const { return true; }

Comments
This bug was introduced in the commit c5500b4b74fb1cb074ff4ba42e24622b7b46fc30. It is found that the latest commit (a merge commit , fcc36ceb0408b60d683ed8628cf03dd828b7b706, Jan 22) cleared up this bug. I encounted and reported this bug just before this commit. ;-) , so I think I can close this JBS. I am sorry about that.
28-01-2021

OK.I will fix this bug by adding `is_late_inline()` under this JBS and report a new JBS (which is an enhancement JDK-8260580 )to merge the `LateInlineVirtualCallGenerator` codes from upstream ASAP.
28-01-2021

As part of JDK-8250740, the implementation was refactored in such a way that there's no need in Compile::inline_incrementally_virtual() anymore. Instead, Compile::inline_incrementally()/inline_incrementally_one() handle LateInlineVirtualCallGenerator.
28-01-2021

It is found that in JDK-8250740 , we disable the optimization of `virtual lateinline` by removing inline_incrementally_virtual. Do we still need this optimization in panama/vectorIntrinsics?
28-01-2021

in https://github.com/openjdk/jdk/blob/764111ff831096729eb1bcc69a54d92fde67b044/src/hotspot/share/opto/callGenerator.cpp#L463 and https://github.com/openjdk/jdk16/blob/685c03dc4899e4f43e830d516b751969ed20ec21/src/hotspot/share/opto/callGenerator.cpp#L463 they already have this line ``` virtual bool is_late_inline() const { return true; } ``` For this reason , I think that jdk/jdk and jdk/jdk16 are both OK.
25-01-2021

Thanks for the clarifications, [~whuang]. I agree with your conclusion. Does it look like a bug introduced by a merge with upstream? As a fix, I propose to migrate vectorIntrinsics branch to the upstream implementation of LateInlineVirtualCallGenerator and prune the remainings of the previous implementation.
25-01-2021

Is it specific to panama/vectorIntrinsics? Considering JDK-8257211 was already upstreamed, I'd expect the problem to be present in 16.
22-01-2021