JDK-8292507 : C2: assert(found) failed: block b is not in n's home loop or an ancestor of it
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 19,20
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • Submitted: 2022-08-16
  • Updated: 2022-09-02
  • Resolved: 2022-09-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 20
20Resolved
Related Reports
Duplicate :  
Relates :  
Description
The following test failed in the JDK20 CI:

applications/javafuzzer/MediumTest.java

Here's a snippet from the log file:

Summary of the JavaFuzzer run:
------------------------------
Host:     win2016-x64-270877
Tests:    12 x 50
Args:     -conf config.yml

Started  at: Tue Aug 16 19:56:36 GMT 2022


r3- 50: 33 passed, 0 crashes, 0 fails, 0 hangs, 0 incorrect tests, 17 Reference Java failures
r12- 50: 33 passed, 0 crashes, 0 fails, 0 hangs, 0 incorrect tests, 17 Reference Java failures
r7- 50: 32 passed, 0 crashes, 0 fails, 0 hangs, 0 incorrect tests, 18 Reference Java failures
r8- 50: 33 passed, 0 crashes, 0 fails, 0 hangs, 0 incorrect tests, 17 Reference Java failures
r6- 50: 34 passed, 0 crashes, 0 fails, 0 hangs, 0 incorrect tests, 16 Reference Java failures
r11- 50: 29 passed, 0 crashes, 0 fails, 0 hangs, 0 incorrect tests, 21 Reference Java failures
r1- 50: 34 passed, 0 crashes, 0 fails, 0 hangs, 0 incorrect tests, 16 Reference Java failures
r9- 50: 28 passed, 0 crashes, 0 fails, 0 hangs, 0 incorrect tests, 22 Reference Java failures
r4- 50: 31 passed, 0 crashes, 0 fails, 0 hangs, 0 incorrect tests, 19 Reference Java failures
r5- 50: 30 passed, 0 crashes, 0 fails, 0 hangs, 0 incorrect tests, 20 Reference Java failures
r2- 50: 25 passed, 0 crashes, 0 fails, 0 hangs, 0 incorrect tests, 25 Reference Java failures
r10- 50: 25 passed, 2 crashes, 0 fails, 0 hangs, 0 incorrect tests, 24 Reference Java failures

Finished at: Tue Aug 16 21:21:27 GMT 2022


#
# A fatal error has been detected by the Java Runtime Environment:
#
#  Internal Error (c:\\sb\\prod\\1660600762\\workspace\\open\\src\\hotspot\\share\\opto\\block.cpp:1223), pid=11460, tid=5576
#  assert(found) failed: block b is not in n's home loop or an ancestor of it
#
# JRE version: Java(TM) SE Runtime Environment (20.0+11) (fastdebug build 20-ea+11-635)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (fastdebug 20-ea+11-635, compiled mode, sharing, tiered, compressed oops, compressed class ptrs, g1 gc, windows-amd64)
# Core dump will be written. Default location: C:\\sb\\prod\\1660679683\\testoutput\\test-support\\jtreg_closed_test_hotspot_jtreg_applications_javafuzzer_MediumTest_java\\tmp\\fuzzer.tmp.3G2vOyvHxh\\hs_err_pid11460.mdmp
#
# If you would like to submit a bug report, please visit:
#   https://bugreport.java.com/bugreport/crash.jsp
#

Command Line: -Xmx1G -Xcomp -Xbatch -XX:CompileOnly=Test -XX:CompileCommand=quiet Test

Here's the crashing thread's stack:

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

Current thread (0x000001cc37df8aa0):  JavaThread "C2 CompilerThread0" daemon [_thread_in_native, id=5576, stack(0x000000432d200000,0x000000432d300000)]


Current CompileTask:
C2:   1064   78   !b  4       Test::mainTest (749 bytes)

Stack: [0x000000432d200000,0x000000432d300000]
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
V  [jvm.dll+0xc43d61]  os::win32::platform_print_native_stack+0xf1  (os_windows_x86.cpp:236)
V  [jvm.dll+0xe97f6e]  VMError::report+0x10de  (vmError.cpp:839)
V  [jvm.dll+0xe9999e]  VMError::report_and_die+0x65e  (vmError.cpp:1687)
V  [jvm.dll+0xe9a114]  VMError::report_and_die+0x64  (vmError.cpp:1468)
V  [jvm.dll+0x58cdc7]  report_vm_error+0xb7  (debug.cpp:284)
V  [jvm.dll+0x33b863]  PhaseCFG::verify_memory_writer_placement+0xc3  (block.cpp:1224)
V  [jvm.dll+0x730d49]  PhaseCFG::hoist_to_cheaper_block+0x3c9  (gcm.cpp:1228)
V  [jvm.dll+0x734ace]  PhaseCFG::schedule_late+0x66e  (gcm.cpp:1456)
V  [jvm.dll+0x72ff4f]  PhaseCFG::global_code_motion+0x31f  (gcm.cpp:1521)
V  [jvm.dll+0x72eb1a]  PhaseCFG::do_global_code_motion+0x4a  (gcm.cpp:1644)
V  [jvm.dll+0x51f485]  Compile::Code_Gen+0x1d5  (compile.cpp:2936)
V  [jvm.dll+0x51e32a]  Compile::Compile+0x15fa  (compile.cpp:857)
V  [jvm.dll+0x443ed5]  C2Compiler::compile_method+0x145  (c2compiler.cpp:115)
V  [jvm.dll+0x537f80]  CompileBroker::invoke_compiler_on_method+0x980  (compileBroker.cpp:2314)
V  [jvm.dll+0x53552c]  CompileBroker::compiler_thread_loop+0x25c  (compileBroker.cpp:1982)
V  [jvm.dll+0x80262f]  JavaThread::thread_main_inner+0x29f  (javaThread.cpp:700)
V  [jvm.dll+0xe11ba7]  Thread::call_run+0x257  (thread.cpp:229)
V  [jvm.dll+0xc426a8]  thread_native_entry+0xb8  (os_windows.cpp:547)
C  [ucrtbase.dll+0x1fb80]
C  [KERNEL32.DLL+0x84d4]
C  [ntdll.dll+0x51791]
Comments
I've attached a reduced test Reduced.java which results in a slightly different assertion failure which, however, looks like the same issue: $ java -XX:LoopMaxUnroll=2 -Xcomp -XX:CompileOnly=Reduced::test Reduced.java # assert(n->is_Root() || n->is_Region() || n->is_Phi() || n->is_MachMerge() || def_block->dominates(block)) failed: uses must be dominated by definitions I've had a closer look and it turns out that this is similar to JDK-8288941: We are removing the empty predicates (Conv2B/Opaque1) in Compile::cleanup_loop_predicates and afterwards we are applying loop unswitching + pre/main/post + unrolling. Since we've removed the empty predicates, we cannot find the skeleton predicates anymore and we are not copying them to the main loop. When unrolling the loop, we do not have a protection anymore, when Cast nodes are replaced by TOP. The skeleton predicates would have removed the loop but they are not present anymore. This should be fixed by JDK-8288981. I'm therefore closing it as a duplicate of it. JDK-8230382 only seemed to have revealed this existing issue.
02-09-2022

Attachment <Reduced.java> could not be scanned. The system has removed attachment. Please check the file before attempting to upload it again
02-09-2022

[~epeter], please take a look.
17-08-2022

The first bad changeset seems to be this one: commit 06cadb36e05a86a528c8f3bc64c1a42b47ca94a0 Author: Emanuel Peter <emanuel.peter@oracle.com> Date: Mon Feb 28 12:13:35 2022 +0000 8230382: Clean up ConvI2L, CastII and CastLL::Ideal methods Reviewed-by: thartmann, roland
17-08-2022

I bisected the start of the problem to jdk-19+12.
17-08-2022

ILW = C2 crash; with fuzzer test and -Xcomp; disable compilation of affected method = MMM = P3
17-08-2022