JDK-8308892 : Bad graph detected in build_loop_late after JDK-8305635
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 21
  • Priority: P2
  • Status: Closed
  • Resolution: Fixed
  • Submitted: 2023-05-25
  • Updated: 2023-07-11
  • Resolved: 2023-06-02
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 21
21 b26Fixed
Related Reports
Duplicate :  
Relates :  
Relates :  
Description
The following test failed in the JDK21 CI:

java/lang/String/LiteralReplace.java

Here's a snippet from the log file:

----------stdout:(21/1124)*----------
#
# A fatal error has been detected by the Java Runtime Environment:
#
#  EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x00007ffedf8120e2, pid=42888, tid=47848
#
# JRE version: Java(TM) SE Runtime Environment (21.0+25) (build 21-ea+25-LTS-2128)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (21-ea+25-LTS-2128, mixed mode, tiered, compressed oops, compressed class ptrs, g1 gc, windows-amd64)
# Problematic frame:
# V  [jvm.dll+0x5f20e2]  PhaseIdealLoop::build_loop_late_post_work+0x272
#
# Core dump will be written. Default location: C:\\sb\\prod\\1685037075\\testoutput\\test-support\\jtreg_open_test_jdk_tier1_part1\\scratch\\1\\hs_err_pid42888.mdmp
#
# An error report file with more information is saved as:
# C:\\sb\\prod\\1685037075\\testoutput\\test-support\\jtreg_open_test_jdk_tier1_part1\\scratch\\1\\hs_err_pid42888.log
#
# Compiler replay data is saved as:
# C:\\sb\\prod\\1685037075\\testoutput\\test-support\\jtreg_open_test_jdk_tier1_part1\\scratch\\1\\replay_pid42888.log
#
# If you would like to submit a bug report, please visit:
#   https://bugreport.java.com/bugreport/crash.jsp
#
result: Error. Agent communication error: java.net.SocketException: Connection reset; check console log for any additional details

Here's the crashing thread's stack:

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

Current thread (0x0000016054ef6100):  JavaThread "C2 CompilerThread0" daemon [_thread_in_native, id=47848, stack(0x0000005efc300000,0x0000005efc400000) (1024K)]

Current CompileTask:
C2:  87063 4915       4       java.util.regex.Pattern$StartS::match (138 bytes)

Stack: [0x0000005efc300000,0x0000005efc400000],  sp=0x0000005efc3face0,  free space=1003k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
V  [jvm.dll+0x5f20e2]  PhaseIdealLoop::build_loop_late_post_work+0x272  (loopnode.cpp:6064)
V  [jvm.dll+0x5f1e14]  PhaseIdealLoop::build_loop_late+0x214  (loopnode.cpp:5910)
V  [jvm.dll+0x5f0f98]  PhaseIdealLoop::build_and_optimize+0x708  (loopnode.cpp:4407)
V  [jvm.dll+0x251fc4]  PhaseIdealLoop::optimize+0x114  (loopnode.hpp:1201)
V  [jvm.dll+0x24a664]  Compile::Optimize+0xcb4  (compile.cpp:2359)
V  [jvm.dll+0x247ede]  Compile::Compile+0xd4e  (compile.cpp:840)
V  [jvm.dll+0x1c9641]  C2Compiler::compile_method+0xc1  (c2compiler.cpp:121)
V  [jvm.dll+0x257ab9]  CompileBroker::invoke_compiler_on_method+0x739  (compileBroker.cpp:2268)
V  [jvm.dll+0x25609a]  CompileBroker::compiler_thread_loop+0x26a  (compileBroker.cpp:1945)
V  [jvm.dll+0x3ee546]  JavaThread::run+0x116  (javaThread.cpp:704)
V  [jvm.dll+0x7f8558]  Thread::call_run+0xc8  (thread.cpp:227)
V  [jvm.dll+0x6c344d]  os::win32::thread_native_entry+0x7d  (os_windows.cpp:551)
C  [ucrtbase.dll+0x1fb80]
C  [KERNEL32.DLL+0x84d4]
C  [ntdll.dll+0x51791]



With a debug build:

Bad graph detected in build_loop_late
n:  1891  Bool  === _ 1890  [[ 1883 ]] [ne] !orig=[1018] !jvms: Pattern::lambda$negate$7 @ bci:2 (line 5818) 0x800000032::is @ bci:5 Pattern::lambda$and$2 @ bci:12 (line 5795) 0x0000000801061988::is @ bci:9 Pattern$CharProperty::match @ bci:37 (line 4109) Pattern$StartS::match @ bci:44 (line 3820)
early(n):  1934  IfFalse  === 1933  [[ 1827 591 ]] #0 !orig=[1818]
n->in(1):  1890  CmpP  === _ 1006 25  [[ 1891 ]]  !orig=[1017] !jvms: Pattern::lambda$negate$7 @ bci:2 (line 5818) 0x800000032::is @ bci:5 Pattern::lambda$and$2 @ bci:12 (line 5795) 0x0000000801061988::is @ bci:9 Pattern$CharProperty::match @ bci:37 (line 4109) Pattern$StartS::match @ bci:44 (line 3820)
early(n->in(1)):  1934  IfFalse  === 1933  [[ 1827 591 ]] #0 !orig=[1818]
n->in(1)->in(1):  1006  DecodeN  === _ 1005  [[ 1029 1890 ]]  #java/lang/Object *  Oop:java/lang/Object * !orig=[1889],... !jvms: 0x800000032::is @ bci:1 Pattern::lambda$and$2 @ bci:12 (line 5795) 0x0000000801061988::is @ bci:9 Pattern$CharProperty::match @ bci:37 (line 4109) Pattern$StartS::match @ bci:44 (line 3820)
early(n->in(1)->in(1)):  1934  IfFalse  === 1933  [[ 1827 591 ]] #0 !orig=[1818]
n->in(1)->in(2):    25  ConP  === 0  [[ 26 34 140 1178 215 1890 1871 1815 1171 1909 1834 1265 1917 1272 ]]  #null
early(n->in(1)->in(2)):     0  Root  === 0 38 1641 93 1648 124 1614 1579 204 1182 1491 1476 376 391 1107 481 518 565 1649 1200 1293 1276 762 832 856 917 1077 1237  [[ 0 1 3 25 33 40 41 54 55 75 88 108 136 153 157 166 231 1620 316 1619 355 371 399 1299 505 1259 1256 585 650 715 1187 726 1033 971 731 736 748 757 800 801 802 803 813 820 844 860 865 902 905 1688 1715 1724 1728 1923 ]] 

LCA(n):  1926  IfFalse  === 1925  [[ 1883 977 ]] #0 !orig=[1874]
n->out(0):  1883  If  === 1926 1891  [[ 1884 1885 ]] P=0,999999, C=-1,000000
n->out(0)->out(0):  1884  IfTrue  === 1883  [[ 1941 1029 ]] #1
n->out(0)->out(1):  1885  IfFalse  === 1883  [[ 1846 ]] #0

idoms of early "1934 IfFalse":
idom[21]:   1926  IfFalse
idom[20]:   1883  If
idom[19]:   1884  IfTrue
idom[18]:   1941  If
idom[17]:   1942  IfFalse
idom[16]:   1902  If
idom[15]:   1903  IfTrue
idom[14]:   1911  If
idom[13]:   1912  IfTrue
idom[12]:     84  ParsePredicate
idom[11]:     94  IfTrue
idom[10]:   1785  If
idom[9]:    1786  IfTrue
idom[8]:    1929  If
idom[7]:    1930  IfFalse
idom[6]:    1797  If
idom[5]:    1798  IfTrue
idom[4]:    1945  If
idom[3]:    1946  IfFalse
idom[2]:    1809  If
idom[1]:    1810  IfTrue
idom[0]:    1933  If
n:          1934  IfFalse

idoms of (wrong) LCA "1926 IfFalse":
n:         1926  IfFalse

Real LCA of early "1934 IfFalse" (idom[21]) and wrong LCA "1926 IfFalse":
 1926  IfFalse  === 1925  [[ 1883 977 ]] #0 !orig=[1874]

#
# A fatal error has been detected by the Java Runtime Environment:
#
#  Internal Error (/opt/mach5/mesos/work_dir/slaves/741e9afd-8c02-45c3-b2e2-9db1450d0832-S172117/frameworks/1735e8a2-a1db-478c-8104-60c8b0af87dd-0196/executors/79c14d5a-c3a8-484b-8985-95db5d2b9d8b/runs/8a9050ac-9e8d-4077-97c9-481f59b3e962/workspace/open/src/hotspot/share/opto/loopnode.cpp:6060), pid=3591450, tid=3591463
#  assert(false) failed: Bad graph detected in build_loop_late
#
# JRE version: Java(TM) SE Runtime Environment (21.0+25) (fastdebug build 21-ea+25-LTS-2128)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (fastdebug 21-ea+25-LTS-2128, mixed mode, sharing, tiered, compressed oops, compressed class ptrs, g1 gc, linux-amd64)
# Problematic frame:
# V  [libjvm.so+0x1295a04]  PhaseIdealLoop::build_loop_late_post_work(Node*, bool)+0x904

Comments
Here's the log files from my jdk-21+25 stress testing sighting on macosx-aarch64: $ unzip -l jdk-21+25_macosx-aarch64.8308892.zip Archive: jdk-21+25_macosx-aarch64.8308892.zip Length Date Time Name --------- ---------- ----- ---- 262158 06-01-2023 20:53 jdk-21+25_1/failures.macosx-aarch64/LiteralReplace.jtr.slowdebug 103761 06-01-2023 20:53 jdk-21+25_1/failures.macosx-aarch64/hs_err_pid44589.log --------- ------- 365919 2 files
05-06-2023

The fix for this bug is integrated in jdk-21+26-2241.
02-06-2023

Changeset: 7dbdad50 Author: Christian Hagedorn <chagedorn@openjdk.org> Date: 2023-06-02 12:00:11 +0000 URL: https://git.openjdk.org/jdk/commit/7dbdad50a616abb01d60ddd53c1bc464cf8c5eb3
02-06-2023

A pull request was submitted for review. URL: https://git.openjdk.org/jdk/pull/14196 Date: 2023-05-28 22:06:42 +0000
28-05-2023

ILW = C2 assert due to bad graph, intermittent in tier1, disable compilation of affected method = HMM = P2
26-05-2023

I'll have a look. Seems to be quite intermittent as I've never hit that before in my testing.
26-05-2023

Christian, please have a look.
26-05-2023

I can reproduce this with replay compilation and the attached replay file. It's a regression from JDK-8305635.
26-05-2023

This looks like a "normal" crash to me, and probably not related to JDK-8258825 even though it happened on EPYC.
25-05-2023