JDK-8221592 : C2 compilation failed with assert(!q->is_MergeMem())
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 13
  • Priority: P2
  • Status: Closed
  • Resolution: Fixed
  • Submitted: 2019-03-28
  • Updated: 2019-08-15
  • Resolved: 2019-04-29
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 13
13 b19Fixed
Related Reports
Relates :  
Relates :  
Description
Tests:
applications/microbenchmarks/other/Test.java#id191

[jmh] # Warmup Iteration   1: # To suppress the following error report, specify this argument
[jmh] # after -XX: or in .hotspotrc:  SuppressErrorAt=/parse1.cpp:1833
[jmh] #
[jmh] # A fatal error has been detected by the Java Runtime Environment:
[jmh] #
[jmh] #  Internal Error (/scratch/opt/mach5/mesos/work_dir/slaves/2dd962d0-8988-479b-a804-57ab764ada59-S1205/frameworks/1735e8a2-a1db-478c-8104-60c8b0af87dd-0196/executors/f3da5d9c-38fb-444d-8ac9-4f22eec2424c/runs/863429cc-ec37-40e1-bfc3-8eafb89c75b2/workspace/open/src/hotspot/share/opto/parse1.cpp:1833), pid=27233, tid=27249
[jmh] #  Error: assert(!q->is_MergeMem()) failed
[jmh] #
[jmh] # JRE version: Java(TM) SE Runtime Environment (13.0) (fastdebug build 13-internal+0-jdk13-jdk.667)
[jmh] # Java VM: Java HotSpot(TM) 64-Bit Server VM (fastdebug 13-internal+0-jdk13-jdk.667, mixed mode, sharing, compressed oops, g1 gc, linux-amd64)
[jmh] # Problematic frame:
[jmh] # V  [libjvm.so+0x13a61d4]  Parse::merge_memory_edges(MergeMemNode*, int, bool)+0x524

Current CompileTask:
C2: 136682 6838   !         jdk.nashorn.internal.scripts.Script$Recompilation$453$19715AAAAA$\^eval\_::L:50#FindMaxSeparation (1268 bytes)

Stack: [0x00007fc080655000,0x00007fc080756000],  sp=0x00007fc08074f680,  free space=1001k
Native frames: (J=compiled Java code, A=aot compiled Java code, j=interpreted, Vv=VM code, C=native code)
V  [libjvm.so+0x13a61d4]  Parse::merge_memory_edges(MergeMemNode*, int, bool)+0x524
V  [libjvm.so+0x13a67ee]  Parse::merge_common(Parse::Block*, int)+0x2fe
V  [libjvm.so+0x13b2177]  Parse::do_if(BoolTest::mask, Node*)+0x557
V  [libjvm.so+0x13b8c8d]  Parse::do_one_bytecode()+0x298d
V  [libjvm.so+0x13a7ca0]  Parse::do_one_block()+0x650
V  [libjvm.so+0x13a81a3]  Parse::do_all_blocks()+0x113
V  [libjvm.so+0x13aa064]  Parse::Parse(JVMState*, ciMethod*, float)+0xc54
V  [libjvm.so+0x7d6e5c]  ParseGenerator::generate(JVMState*)+0x18c
V  [libjvm.so+0xb4db99]  Parse::do_call()+0x559
V  [libjvm.so+0x13b72f0]  Parse::do_one_bytecode()+0xff0
V  [libjvm.so+0x13a7ca0]  Parse::do_one_block()+0x650
V  [libjvm.so+0x13a81a3]  Parse::do_all_blocks()+0x113
V  [libjvm.so+0x13aa064]  Parse::Parse(JVMState*, ciMethod*, float)+0xc54
V  [libjvm.so+0x7d6e5c]  ParseGenerator::generate(JVMState*)+0x18c
V  [libjvm.so+0xb4db99]  Parse::do_call()+0x559
V  [libjvm.so+0x13b72f0]  Parse::do_one_bytecode()+0xff0
V  [libjvm.so+0x13a7ca0]  Parse::do_one_block()+0x650
V  [libjvm.so+0x13a81a3]  Parse::do_all_blocks()+0x113
V  [libjvm.so+0x13aa064]  Parse::Parse(JVMState*, ciMethod*, float)+0xc54
V  [libjvm.so+0x7d6e5c]  ParseGenerator::generate(JVMState*)+0x18c
V  [libjvm.so+0xb4db99]  Parse::do_call()+0x559
V  [libjvm.so+0x13b72f0]  Parse::do_one_bytecode()+0xff0
V  [libjvm.so+0x13a7ca0]  Parse::do_one_block()+0x650
V  [libjvm.so+0x13a81a3]  Parse::do_all_blocks()+0x113
V  [libjvm.so+0x13aa064]  Parse::Parse(JVMState*, ciMethod*, float)+0xc54
V  [libjvm.so+0x7d6e5c]  ParseGenerator::generate(JVMState*)+0x18c
V  [libjvm.so+0xb4db99]  Parse::do_call()+0x559
V  [libjvm.so+0x13b72f0]  Parse::do_one_bytecode()+0xff0
V  [libjvm.so+0x13a7ca0]  Parse::do_one_block()+0x650
V  [libjvm.so+0x13a81a3]  Parse::do_all_blocks()+0x113
V  [libjvm.so+0x13aa064]  Parse::Parse(JVMState*, ciMethod*, float)+0xc54
V  [libjvm.so+0x7d6e5c]  ParseGenerator::generate(JVMState*)+0x18c
V  [libjvm.so+0x7de9f5]  LateInlineCallGenerator::do_late_inline()+0xfb5
V  [libjvm.so+0x98ec0a]  Compile::inline_incrementally_one()+0x14a
V  [libjvm.so+0x9952d7]  Compile::inline_incrementally(PhaseIterGVN&)+0x187
V  [libjvm.so+0x99807b]  Compile::Optimize()+0x2fb
V  [libjvm.so+0x999e3a]  Compile::Compile(ciEnv*, C2Compiler*, ciMethod*, int, bool, bool, bool, DirectiveSet*)+0x103a
V  [libjvm.so+0x7d4f5d]  C2Compiler::compile_method(ciEnv*, ciMethod*, int, DirectiveSet*)+0x10d
V  [libjvm.so+0x9a678e]  CompileBroker::invoke_compiler_on_method(CompileTask*)+0x43e
V  [libjvm.so+0x9a7688]  CompileBroker::compiler_thread_loop()+0x378
V  [libjvm.so+0x1630faa]  JavaThread::thread_main_inner()+0x26a
V  [libjvm.so+0x1639358]  JavaThread::run()+0x218
V  [libjvm.so+0x1636596]  Thread::call_run()+0xf6
V  [libjvm.so+0x135716d]  thread_native_entry(Thread*)+0x10d
Comments
I was finally able to trace the MergeMems back to this code: http://hg.openjdk.java.net/jdk/jdk/file/47a8fdf84424/src/hotspot/share/opto/parse1.cpp#l1028 The memory input of the _exit map is a MergeMem (41745) with a useless Phi (41744) input that has another MergeMem (37057) as input: (rr) print _exits._map->_in[2]->dump(2) 19775 Proj === 19773 [[ 19759 19759 19759 19759 41708 41708 41708 41708 41716 41716 41716 41716 41718 41718 41718 41718 41726 41726 41726 41726 41730 41730 41730 41730 41738 41738 41738 41738 41740 41740 41740 41740 41748 41748 41748 41748 41751 41752 41753 41754 ]] #2 Memory: @rawptr:BotPTR, idx=Raw; !jvms: Script$Recompilation$453$19715AAAAA$\^eval\_::L:50#FindMaxSeparation @ bci:1022 37057 MergeMem === _ 1 37093 37094 1 1 37095 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 37096 1 1 37097 1 1 1 1 1 37098 37099 37100 37101 37102 37103 37104 37105 [[ 37058 37064 37070 37077 37083 19776 19759 19760 4968 4968 18862 41708 41716 41718 41726 41730 41738 41740 41748 41744 ]] { N37094:rawptr:BotPTR - - N37095:java/lang/Object+8 * [narrowklass] - - - - - - - - - - - - - - - - N37096:java/lang/Throwable+16 * [narrow] - - N37097:java/lang/Object * - - - - - N37098:java/lang/Throwable+12 * [narrow] N37099:java/lang/Throwable+20 * [narrow] N37100:java/lang/Throwable+24 * [narrow] N37101:java/lang/Throwable+28 * [narrow] N37102:java/lang/Throwable+32 * N37103:jdk/nashorn/internal/runtime/UnwarrantedOptimismException:exact+36 * N37104:jdk/nashorn/internal/runtime/UnwarrantedOptimismException:exact+40 * [narrow] N37105:jdk/nashorn/internal/runtime/UnwarrantedOptimismException:exact+44 * [narrow] } Memory: @BotPTR *+bot, idx=Bot; !jvms: 0x0000000100487840::delegate @ bci:-1 0x0000000100454040::guard @ bci:94 0x0000000100487840::delegate @ bci:25 0x0000000100454040::guard @ bci:94 0x0000000100451440::linkToCallSite @ bci:25 Script$Recompilation$453$19715AAAAA$\^eval\_::L:50#FindMaxSeparation @ bci:523 41742 Region === _ 19774 [[ 41754 41753 41743 41744 41746 41751 41752 41741 ]] !jvms: 0x000000010009b840::invokeStatic @ bci:1 0x000000010045a040::invoke @ bci:21 0x000000010045a840::linkToTargetMethod @ bci:18 Script$Recompilation$453$19715AAAAA$\^eval\_::L:50#FindMaxSeparation @ bci:1039 41754 Phi === 41742 19775 [[ 41745 ]] #memory Memory: @java/lang/Object *, idx=26; !orig=41744 !jvms: 0x000000010009b840::invokeStatic @ bci:1 0x000000010045a040::invoke @ bci:21 0x000000010045a840::linkToTargetMethod @ bci:18 Script$Recompilation$453$19715AAAAA$\^eval\_::L:50#FindMaxSeparation @ bci:1039 41753 Phi === 41742 19775 [[ 41745 ]] #memory Memory: @narrowoop: java/lang/Object *[int:>=0]+any * [narrow], idx=14; !orig=41744 !jvms: 0x000000010009b840::invokeStatic @ bci:1 0x000000010045a040::invoke @ bci:21 0x000000010045a840::linkToTargetMethod @ bci:18 Script$Recompilation$453$19715AAAAA$\^eval\_::L:50#FindMaxSeparation @ bci:1039 41752 Phi === 41742 19775 [[ 41745 ]] #memory Memory: @java/lang/Object+8 * [narrowklass], idx=6; !orig=41744 !jvms: 0x000000010009b840::invokeStatic @ bci:1 0x000000010045a040::invoke @ bci:21 0x000000010045a840::linkToTargetMethod @ bci:18 Script$Recompilation$453$19715AAAAA$\^eval\_::L:50#FindMaxSeparation @ bci:1039 41751 Phi === 41742 19775 [[ 41745 ]] #memory Memory: @rawptr:BotPTR, idx=Raw; !orig=41744 !jvms: 0x000000010009b840::invokeStatic @ bci:1 0x000000010045a040::invoke @ bci:21 0x000000010045a840::linkToTargetMethod @ bci:18 Script$Recompilation$453$19715AAAAA$\^eval\_::L:50#FindMaxSeparation @ bci:1039 41744 Phi === 41742 37057 [[]] #memory Memory: @BotPTR *+bot, idx=Bot; !jvms: 0x000000010009b840::invokeStatic @ bci:1 0x000000010045a040::invoke @ bci:21 0x000000010045a840::linkToTargetMethod @ bci:18 Script$Recompilation$453$19715AAAAA$\^eval\_::L:50#FindMaxSeparation @ bci:1039 41745 MergeMem === _ 1 41744 41751 1 1 41752 1 1 1 1 1 1 1 41753 1 1 1 1 1 1 1 1 1 1 1 41754 [[ 41741 ]] { N41751:rawptr:BotPTR - - N41752:java/lang/Object+8 * [narrowklass] - - - - - - - N41753:narrowoop: java/lang/Object *[int:>=0]+any * [narrow] - - - - - - - - - - - N41754:java/lang/Object * } Memory: @BotPTR *+bot, idx=Bot; !jvms: 0x000000010009b840::invokeStatic @ bci:1 0x000000010045a040::invoke @ bci:21 0x000000010045a840::linkToTargetMethod @ bci:18 Script$Recompilation$453$19715AAAAA$\^eval\_::L:50#FindMaxSeparation @ bci:1039 After calling transform on this slice, the Phi is removed and we end up with a MergeMem that is then set as input to the _exit MergeMem. Much later, this triggers the assert. Proposed fix: diff -r b43cc3b9ef40 src/hotspot/share/opto/parse1.cpp --- a/src/hotspot/share/opto/parse1.cpp Thu Apr 25 09:12:40 2019 +0200 +++ b/src/hotspot/share/opto/parse1.cpp Fri Apr 26 13:24:53 2019 +0200 @@ -1028,6 +1028,8 @@ // transform each slice of the original memphi: mms.set_memory(_gvn.transform(mms.memory())); } + // Clean up input MergeMems created by transforming the slices + _gvn.transform(_exits.merged_memory()); if (tf()->range()->cnt() > TypeFunc::Parms) { const Type* ret_type = tf()->range()->field_at(TypeFunc::Parms);
26-04-2019

I was able to narrow it down to the fix for JDK-8059241. 41806 MergeMem === _ 1 41842 41843 1 1 41844 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 41845 1 1 41846 1 1 1 1 1 41847 41848 41849 41850 41851 41852 41853 41854 [[ 41807 41813 41819 41826 41832 19817 19800 19801 5375 5375 18903 46784 46792 46794 46802 46806 46814 46816 46824 46820 46821 46831 46839 46842 46850 46859 46869 ]] { N41843:rawptr:BotPTR - - N41844:java/lang/Object+8 * [narrowklass] - - - - - - - - - - - - - - - - N41845:java/lang/Throwable+16 * [narrow] - - N41846:java/lang/Object * - - - - - N41847:java/lang/Throwable+12 * [narrow] N41848:java/lang/Throwable+20 * [narrow] N41849:java/lang/Throwable+24 * [narrow] N41850:java/lang/Throwable+28 * [narrow] N41851:java/lang/Throwable+32 * N41852:jdk/nashorn/internal/runtime/UnwarrantedOptimismException:exact+36 * N41853:jdk/nashorn/internal/runtime/UnwarrantedOptimismException:exact+40 * [narrow] N41854:jdk/nashorn/internal/runtime/UnwarrantedOptimismException:exact+44 * [narrow] } Memory: @BotPTR *+bot, idx=Bot; !jvms: 0x00000001004b6440::delegate @ bci:-1 0x0000000100482440::guard @ bci:94 0x00000001004b6440::delegate @ bci:25 0x0000000100482440::guard @ bci:94 0x000000010047f840::linkToCallSite @ bci:25 Script$Recompilation$453$19715AAAAA$\^eval\_::L:50#FindMaxSeparation @ bci:523 46869 MergeMem === _ 1 41806 19816 1 1 19816 1 1 1 1 1 1 1 19816 1 1 1 1 1 1 1 1 1 1 1 19816 [[ 46870 ]] { N19816:rawptr:BotPTR - - N19816:java/lang/Object+8 * [narrowklass] - - - - - - - N19816:narrowoop: java/lang/Object *[int:>=0]+any * [narrow] - - - - - - - - - - - N19816:java/lang/Object * } Memory: @BotPTR *+bot, idx=Bot; !jvms: Integer::valueOf @ bci:10 ValueConversions::boxInteger @ bci:1 0x000000010016e440::invokeStatic @ bci:10 0x0000000100488440::invoke @ bci:21 0x0000000100488c40::linkToTargetMethod @ bci:18 Script$Recompilation$453$19715AAAAA$\^eval\_::L:50#FindMaxSeparation @ bci:1039 46870 SafePoint === 46868 19812 46869 8 1 18842 1 1 1 1 [[]] SafePoint !orig=46851,46849 !jvms: ValueConversions::boxInteger @ bci:1 0x000000010016e440::invokeStatic @ bci:10 0x0000000100488440::invoke @ bci:21 0x0000000100488c40::linkToTargetMethod @ bci:18 Script$Recompilation$453$19715AAAAA$\^eval\_::L:50#FindMaxSeparation @ bci:1039 q = 41806 n = 46869 Usually, such MergeMems feeding into other MergMems should be cleaned up by: http://hg.openjdk.java.net/jdk/jdk/file/47a8fdf84424/src/hotspot/share/opto/graphKit.cpp#l1945 There are lots of SafePoint nodes with no output around but that might be okay during that stage or parsing. I'll dig deeper.
25-04-2019

for the reference, other#id191 run oracle.micro.benchmarks.script.octane.Box2DBench.test from micros-uberpackage-1.21.
28-03-2019

ILW = Assert in C2 during parsing, with single microbenchmark, no known workaround = HLH = P2
28-03-2019