JDK-8295407 : C2 crash: Error: ShouldNotReachHere() in multiple vector tests with -XX:-MonomorphicArrayCheck -XX:-UncommonNullCast
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 20
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2022-10-17
  • Updated: 2022-12-14
  • Resolved: 2022-11-17
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
20 b25Fixed
Related Reports
Relates :  
Description
I ran the following tests with extra compiler flags:
-XX:+IgnoreUnrecognizedVMOptions -XX:-MonomorphicArrayCheck -XX:-UncommonNullCast

So far only seen it on aarch64 (linux / macosx)

jdk/incubator/vector/Float512VectorTests.java
jdk/incubator/vector/Vector128ConversionTests.java
jdk/incubator/vector/VectorMaxConversionTests.java

Error mixing types: vectorx[4]:{float_top} and float_top 

# To suppress the following error report, specify this argument
# after -XX: or in .hotspotrc:  SuppressErrorAt=/type.cpp:1179
#
# A fatal error has been detected by the Java Runtime Environment:
#
#  Internal Error (/opt/mach5/mesos/work_dir/slaves/0c72054a-24ab-4dbb-944f-97f9341a1b96-S107603/frameworks/1735e8a2-a1db-478c-8104-60c8b0af87dd-0196/executors/57d56251-e15d-4be2-a96f-2fece2c8162e/runs/971fce5c-2e86-4644-94a9-92f392cad7dc/workspace/open/src/hotspot/share/opto/type.cpp:1179), pid=1036744, tid=1036759
#  Error: ShouldNotReachHere()
#
# JRE version: Java(TM) SE Runtime Environment (20.0) (fastdebug build 20-internal-2022-10-14-0755324.emanuel.peter.fork3-jdk)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (fastdebug 20-internal-2022-10-14-0755324.emanuel.peter.fork3-jdk, mixed mode, sharing, compressed oops, compressed class ptrs, g1 gc, linux-aarch64)
# Problematic frame:
# V  [libjvm.so+0x17d8378]  Type::typerr(Type const*) const+0x84
#
# Core dump will be written. Default location: Core dumps may be processed with "/opt/core.sh %p" (or dumping to /opt/mach5/mesos/work_dir/slaves/0c72054a-24ab-4dbb-944f-97f9341a1b96-S48953/frameworks/1735e8a2-a1db-478c-8104-60c8b0af87dd-0196/executors/6a05eca0-8afd-44ed-bb10-6608b5100f7c/runs/24fb71ad-6cc1-49b1-bb99-393b164a2865/testoutput/test-support/jtreg_open_test_jdk_jdk_vector/scratch/3/core.1036744)
#
# An error report file with more information is saved as:
# /opt/mach5/mesos/work_dir/slaves/0c72054a-24ab-4dbb-944f-97f9341a1b96-S48953/frameworks/1735e8a2-a1db-478c-8104-60c8b0af87dd-0196/executors/6a05eca0-8afd-44ed-bb10-6608b5100f7c/runs/24fb71ad-6cc1-49b1-bb99-393b164a2865/testoutput/test-support/jtreg_open_test_jdk_jdk_vector/scratch/3/hs_err_pid1036744.log
Comments
Changeset: cc444198 Author: Fei Gao <fgao@openjdk.org> Committer: Pengfei Li <pli@openjdk.org> Date: 2022-11-17 01:39:56 +0000 URL: https://git.openjdk.org/jdk/commit/cc44419840d98fed0bcdab66bbb835855f1a8a11
17-11-2022

I moved files to that bug.
16-11-2022

Vector512ConversionTests.java failure looks like JDK-8276064.
16-11-2022

I got 2 new failures which I did not see before. First could be not related (but who knows): Running tier1_compiler_3 tests with stress testing flag -XX:StressLongCountedLoop=2000000 caused Exception in thread "main" java.lang.ClassFormatError: Unknown constant tag 0 in class file net/logstash/logback/encoder/org/apache/commons/lang/text/StrBuilder at java.base/java.lang.ClassLoader.defineClass1(Native Method) at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1012) at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:150) Second could be related or not. Test jdk/incubator/vector/Vector512ConversionTests.java failed (1 time from 3 runs) on AVX512 machine with -XX:+IgnoreUnrecognizedVMOptions -XX:-MonomorphicArrayCheck -XX:-UncommonNullCast flags: # # Internal Error (/workspace/open/src/hotspot/share/opto/buildOopMap.cpp:350), pid=3803, tid=3850 # assert(false) failed: there should be a oop in OopMap instead of a live raw oop at safepoint # I attached hs_err and replay files.
16-11-2022

A pull request was submitted for review. URL: https://git.openjdk.org/jdk/pull/11034 Date: 2022-11-08 02:36:13 +0000
08-11-2022

Hi [~thartmann], thanks for reporting it and bisecting work. For the loop like: ``` // float[] a, c; // boolean[] mask; for (int i = 0; i < a.length; i++) { c[i] = mask[i]? -a[i]: a[i]; } ``` it generates `CMoveF` nodes but superword can’t vectorize it, even if enabling `-XX:+UseCMoveUnconditionally -XX:+UseVectorCmov`. ``` Node_1 = CmpI LoadUB ConI Node_2 = Bool Node_1 mask Node_3 = CMoveF Node_2 NegF LoadF ``` Currently, only when enabling `UseVectorCmov`, superword will remove these unqualified `CMoveF` nodes from the pack candidate set, see https://github.com/openjdk/jdk/blob/b2878c904beb971da37b1da50a7294c460d6cef3/src/hotspot/share/opto/superword.cpp#L537. Without the option enabled, the `CMoveF` pack is kept in the packset and thus superword wrongly vectorizes its input `NegF` and `LoadF`. Finally, we get a scalar `CMoveF` node with two vector inputs, `NegVF` and `LoadVF`, which has wrong mixing types, then the assertion fails. Also, considering that superword redefined the semantics of `CMoveVF`, containing the behavior of `VectorMaskCmp` + `VectorBlend` requiring for the same inputs, which is largely different from the semantics of scalar `CMoveF`, we need to check if the `CMoveF` is in a merged cmove pack, besides consulting whether the single scalar `CMoveF` is supported for vectorization in the current platform, https://github.com/openjdk/jdk/blob/b2878c904beb971da37b1da50a7294c460d6cef3/src/hotspot/share/opto/superword.cpp#L2103. I'll propose a patch to fix it ASAP. Thanks.
26-10-2022

[~fgao], could you please have a look? Thanks.
25-10-2022

Seems to be a regression in JDK 20, at least I can not reproduce with latest JDK 19. Update: I narrowed it down to JDK-8289422 in JDK 20 b17.
25-10-2022

ILW = Assertion failure in C2, only with -XX:-MonomorphicArrayCheck -XX:-UncommonNullCast, use -XX:+MonomorphicArrayCheck and/or -XX:+UncommonNullCast = HLM = P3
17-10-2022