JDK-8286451 : C2: assert(nb == 1) failed: only when the head is not shared
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 19
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2022-05-10
  • Updated: 2022-06-20
  • Resolved: 2022-06-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 19
19 b26Fixed
Related Reports
Relates :  
Description
Fastdebug JVM crashes when run dacapo with ZGC. 

This bug could be reproduced at least on x86_64, aarch64 and riscv Linux platforms with jdk master commit:

aaeb08eca422776eef5955473734aad75cb2829a (HEAD -> master, origin/master, origin/HEAD)
Author: Leonid Mesnik <lmesnik@openjdk.org>
Date:   Tue May 10 22:28:12 2022 +0000

$ java -version
openjdk version "19-internal" 2022-09-20
OpenJDK Runtime Environment (fastdebug build 19-internal-adhoc.yangfei.jdk-upstream)
OpenJDK 64-Bit Server VM (fastdebug build 19-internal-adhoc.yangfei.jdk-upstream, mixed mode, sharing)

To reproduce on x86_64 Linux platform, do:
$ java -XX:+UseZGC -jar dacapo-9.12-MR1-bach.jar -s small avrora fop h2 jython lusearch lusearch-fix xalan pmd

(the DaCapo JAR is available at https://jztkft.dl.sourceforge.net/project/dacapobench/9.12-bach-MR1/dacapo-9.12-MR1-bach.jar)

#
# A fatal error has been detected by the Java Runtime Environment:
#
#  Internal Error (/home/yangfei/jdk-upstream/src/hotspot/share/ci/ciTypeFlow.cpp:2332), pid=19654, tid=19800
#  assert(nb == 1) failed: only when the head is not shared
#
# JRE version: OpenJDK Runtime Environment (19.0) (fastdebug build 19-internal-adhoc.yangfei.jdk-upstream)
# Java VM: OpenJDK 64-Bit Server VM (fastdebug 19-internal-adhoc.yangfei.jdk-upstream, mixed mode, sharing, tiered, compressed class ptrs, z gc, linux-amd64)
# Problematic frame:
# V  [libjvm.so+0x91ea50]  ciTypeFlow::clone_loop_head(ciTypeFlow::Loop*, ciTypeFlow::StateVector*, ciTypeFlow::JsrSet*)+0x8f0
#
# No core dump will be written. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
#
# 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: -XX:+UseZGC dacapo-9.12-MR1-bach.jar -s small avrora fop h2 jython lusearch lusearch-fix xalan pmd

Host: ubuntu18, Intel(R) Xeon(R) CPU E5-2690 v3 @ 2.60GHz, 48 cores, 377G, Ubuntu 18.04.2 LTS
Time: Wed May 11 08:43:31 2022 CST elapsed time: 12.816312 seconds (0d 0h 0m 12s)

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

Current thread (0x00007feaa81c6980):  JavaThread "C2 CompilerThread7" daemon [_thread_in_native, id=19800, stack(0x00007feb1563a000,0x00007feb1573b000)]


Current CompileTask:
C2:  12816 4494 %     4       org.h2.util.ObjectArray::sort @ 115 (289 bytes)

Stack: [0x00007feb1563a000,0x00007feb1573b000],  sp=0x00007feb15737970,  free space=1014k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
V  [libjvm.so+0x91ea50]  ciTypeFlow::clone_loop_head(ciTypeFlow::Loop*, ciTypeFlow::StateVector*, ciTypeFlow::JsrSet*)+0x8f0
V  [libjvm.so+0x91ebd1]  ciTypeFlow::clone_loop_heads(ciTypeFlow::StateVector*, ciTypeFlow::JsrSet*)+0xf1
V  [libjvm.so+0x91fab4]  ciTypeFlow::flow_types()+0x734
V  [libjvm.so+0x920056]  ciTypeFlow::do_flow()+0x26
V  [libjvm.so+0x8bd8f4]  ciMethod::get_flow_analysis()+0x64
V  [libjvm.so+0x6e5661]  InlineTree::check_can_parse(ciMethod*)+0xf1
V  [libjvm.so+0x82ee88]  CallGenerator::for_osr(ciMethod*, int)+0x18
V  [libjvm.so+0x9d3d7a]  Compile::Compile(ciEnv*, ciMethod*, int, Options, DirectiveSet*)+0xfca
V  [libjvm.so+0x829dfe]  C2Compiler::compile_method(ciEnv*, ciMethod*, int, bool, DirectiveSet*)+0x38e
V  [libjvm.so+0x9e0a79]  CompileBroker::invoke_compiler_on_method(CompileTask*)+0x9c9
V  [libjvm.so+0x9e1550]  CompileBroker::compiler_thread_loop()+0x400
V  [libjvm.so+0x18e7b23]  JavaThread::thread_main_inner()+0x1f3
V  [libjvm.so+0x18f4ca6]  Thread::call_run()+0xf6
V  [libjvm.so+0x14cbfa4]  thread_native_entry(Thread*)+0x104

Register to memory mapping:

RAX=0x00007fede077d000 points into unknown readable memory: 0x0000000000000058 | 58 00 00 00 00 00 00 00
RBX=0x00007feb157379d0 is pointing into the stack for thread: 0x00007feaa81c6980
RCX=0x00007feddf1067b0: <offset 0x0000000001b687b0> in /home/yangfei/install-fastdebug/jvm/openjdk-19-internal/lib/server/libjvm.so at 0x00007feddd59e000
RDX=0x00007feddf1055b6: <offset 0x0000000001b675b6> in /home/yangfei/install-fastdebug/jvm/openjdk-19-internal/lib/server/libjvm.so at 0x00007feddd59e000
RSP=0x00007feb15737970 is pointing into the stack for thread: 0x00007feaa81c6980
RBP=0x00007feb15737a20 is pointing into the stack for thread: 0x00007feaa81c6980
RSI=0x000000000000091c is an unknown value
RDI=0x00007feddf1057b0: <offset 0x0000000001b677b0> in /home/yangfei/install-fastdebug/jvm/openjdk-19-internal/lib/server/libjvm.so at 0x00007feddd59e000
R8 =0x00007feddf83fe38: <offset 0x00000000022a1e38> in /home/yangfei/install-fastdebug/jvm/openjdk-19-internal/lib/server/libjvm.so at 0x00007feddd59e000
R9 =0x0000000000000100 is an unknown value
R10=0x0000000000000001 is an unknown value
R11=0x0000000000000002 is an unknown value
R12=0x00007fea9c0bac68 points into unknown readable memory: 0x00007feddf744e00 | 00 4e 74 df ed 7f 00 00
R13=0x00007feab436eba0 points into unknown readable memory: 0x00007feddf744e00 | 00 4e 74 df ed 7f 00 00
R14=0x00007feab436eff0 points into unknown readable memory: 0x00007feddf7f3e70 | 70 3e 7f df ed 7f 00 00
R15=0x00007fea9c0bac68 points into unknown readable memory: 0x00007feddf744e00 | 00 4e 74 df ed 7f 00 00


Registers:
RAX=0x00007fede077d000, RBX=0x00007feb157379d0, RCX=0x00007feddf1067b0, RDX=0x00007feddf1055b6
RSP=0x00007feb15737970, RBP=0x00007feb15737a20, RSI=0x000000000000091c, RDI=0x00007feddf1057b0
R8 =0x00007feddf83fe38, R9 =0x0000000000000100, R10=0x0000000000000001, R11=0x0000000000000002
R12=0x00007fea9c0bac68, R13=0x00007feab436eba0, R14=0x00007feab436eff0, R15=0x00007fea9c0bac68
RIP=0x00007fedddebca50, EFLAGS=0x0000000000010202, CSGSFS=0x002b000000000033, ERR=0x0000000000000006
  TRAPNO=0x000000000000000e

Top of Stack: (sp=0x00007feb15737970)
0x00007feb15737970:   00007feb157379c0 00007fedddebac12
0x00007feb15737980:   00007fea9c0bac68 00007feb157379c8
0x00007feb15737990:   00007fea00000002 00007feaa42ffae8
0x00007feb157379a0:   00007feaa42ffaa8 00007feb001645f8 

Instructions: (pc=0x00007fedddebca50)
0x00007fedddebc950:   00 00 00 48 c7 45 b0 00 00 00 00 e8 10 40 cb ff
0x00007fedddebc960:   48 85 c0 49 89 c4 74 14 48 8b 75 88 48 89 d9 ba
0x00007fedddebc970:   04 00 00 00 48 89 c7 e8 94 5c ff ff 48 8b 45 98
0x00007fedddebc980:   48 8b 40 40 4e 89 24 e8 e9 aa f8 ff ff 83 bd 70
0x00007fedddebc990:   ff ff ff 01 0f 85 92 00 00 00 48 8b 55 80 48 8b
0x00007fedddebc9a0:   8d 78 ff ff ff 48 8b 7d 98 e8 d2 ed ff ff 48 8d
0x00007fedddebc9b0:   05 5b 74 93 01 48 89 df c7 45 c0 ff ff ff ff 48
0x00007fedddebc9c0:   c7 45 c8 00 00 00 00 48 89 45 b0 48 8b 45 a0 48
0x00007fedddebc9d0:   89 45 b8 e8 78 e0 ff ff 8b 55 c0 85 d2 78 26 4c
0x00007fedddebc9e0:   3b 7d c8 75 11 e9 7e 00 00 00 66 0f 1f 44 00 00
0x00007fedddebc9f0:   4c 39 7d c8 74 72 48 89 df e8 52 e0 ff ff 8b 45
0x00007fedddebca00:   c0 85 c0 79 eb 48 8b 75 a0 e9 7e fc ff ff b8 01
0x00007fedddebca10:   00 00 00 e9 2b fd ff ff 48 89 c7 e8 60 5e ff ff
0x00007fedddebca20:   41 89 c4 48 8b 45 90 e9 17 fa ff ff 4c 8d 05 05
0x00007fedddebca30:   34 98 01 49 8b 00 48 8d 0d 73 9d 24 01 48 8d 15
0x00007fedddebca40:   72 8b 24 01 48 8d 3d 65 8d 24 01 be 1c 09 00 00
0x00007fedddebca50:   c6 00 58 31 c0 e8 f6 d4 15 00 e8 51 74 ba 00 48
0x00007fedddebca60:   8b 75 a0 e9 32 ff ff ff 48 8b 75 a0 48 89 df 48
0x00007fedddebca70:   8d 5d a0 e8 58 eb ff ff 49 8d 7f 38 48 89 de e8
0x00007fedddebca80:   2c 2e 00 00 48 8b 45 a0 48 89 de 48 8d 78 38 e8
0x00007fedddebca90:   fc 33 00 00 48 8b 75 a0 e9 ef fb ff ff 4c 8d 05
0x00007fedddebcaa0:   94 33 98 01 48 8d 0d fd 96 24 01 48 8d 15 1e 97
0x00007fedddebcab0:   24 01 48 8d 3d f7 8c 24 01 be 19 08 00 00 49 8b
0x00007fedddebcac0:   00 c6 00 58 31 c0 e8 85 d4 15 00 e8 e0 73 ba 00
0x00007fedddebcad0:   e9 2a f8 ff ff 90 66 2e 0f 1f 84 00 00 00 00 00
0x00007fedddebcae0:   55 48 89 e5 41 57 41 56 41 55 41 54 49 89 fe 53
0x00007fedddebcaf0:   48 83 ec 28 4c 8b 67 60 48 89 75 c0 48 89 55 b8
0x00007fedddebcb00:   c6 45 c8 00 4c 89 e3 48 85 db 0f 84 fc 00 00 00
0x00007fedddebcb10:   49 3b 5e 60 0f 84 06 01 00 00 80 7b 40 00 0f 85
0x00007fedddebcb20:   fc 00 00 00 4c 8b 6b 30 48 89 de 4c 89 ef e8 ad
0x00007fedddebcb30:   e1 ff ff 84 c0 41 89 c7 0f 84 e2 00 00 00 48 8d
0x00007fedddebcb40:   05 dc 4b 98 01 80 38 00 74 0e 41 80 bd 92 00 00 


Stack slot to memory mapping:
stack at sp + 0 slots: 0x00007feb157379c0 is pointing into the stack for thread: 0x00007feaa81c6980
stack at sp + 1 slots: 0x00007fedddebac12: <offset 0x000000000091cc12> in /home/yangfei/install-fastdebug/jvm/openjdk-19-internal/lib/server/libjvm.so at 0x00007feddd59e000
stack at sp + 2 slots: 0x00007fea9c0bac68 points into unknown readable memory: 0x00007feddf744e00 | 00 4e 74 df ed 7f 00 00
stack at sp + 3 slots: 0x00007feb157379c8 is pointing into the stack for thread: 0x00007feaa81c6980
stack at sp + 4 slots: 0x00007fea00000002 is an unknown value
stack at sp + 5 slots: 0x00007feaa42ffae8 points into unknown readable memory: 0x00007feddf7f3e90 | 90 3e 7f df ed 7f 00 00
stack at sp + 6 slots: 0x00007feaa42ffaa8 points into unknown readable memory: 0x00007feddf7f3eb0 | b0 3e 7f df ed 7f 00 00
stack at sp + 7 slots: 0x00007feb001645f8 is an unknown value
Comments
Changeset: bf0e625f Author: Roland Westrelin <roland@openjdk.org> Date: 2022-06-08 06:41:20 +0000 URL: https://git.openjdk.java.net/jdk/commit/bf0e625fe0e83c00006f13367a67e9f6175d21e4
08-06-2022

A pull request was submitted for review. URL: https://git.openjdk.java.net/jdk/pull/8947 Date: 2022-05-30 13:50:08 +0000
30-05-2022

Assert was introduced by JDK-8279888 in JDK 19 b20: https://github.com/openjdk/jdk/commit/32593df392cfd139e10849c2a5db0a377fd1ce9c#diff-67c933de6d66468bc2bb9df38a26d63caa4002f2e177bc6c3616d5cd26fedbf2R2332 Roland, could you please have a look?
11-05-2022

Attached the hs_err and replay files from two crashes. The method under compilation is, in both cases, org.h2.util.ObjectArray::sort, but the compilation mode differs (regular vs. OSR).
11-05-2022

ILW = assertion failure in debug build; intermittent failure on standard benchmark suite using -XX:+UseZGC; no know workaround = MMH = P3
11-05-2022

Thank you for the additional information [~fyang], I did manage to reproduce the failure now using commit aaeb08e in my environment (x86_64, Intel(R) Core(TM) i7-9850H CPU @ 2.60GHz, 12 cores, 31G, Ubuntu 20.04.1 LTS).
11-05-2022

[~rcastanedalo] I have add jdk master commit infomation in the description. Could you please try again? With a jdk fastdebug build, I see this bug can be easily reproduced on my side after 3-4 dacapo runs on x86_64, aarch64 and riscv Linux platforms.
11-05-2022

Added necessary jdk master commit information for reproduce purpose.
11-05-2022

[~fyang] Setting resolution as "incomplete" temporarily while awaiting for further information, please re-open the issue when providing the additional build details, thanks!
10-05-2022

[~fyang] could you please share more details about the build where you are seeing these failures? (build number or specific git commit). I cannot reproduce it locally using a range of JDK 19 builds.
10-05-2022