JDK-8331252 : C2: MergeStores: handle negative shift values
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 23
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2024-04-29
  • Updated: 2024-05-06
  • Resolved: 2024-04-30
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 23
23 b21Fixed
Related Reports
Relates :  
Description
Test: applications/javafuzzer/BigTest.java

#
# A fatal error has been detected by the Java Runtime Environment:
#
#  Internal Error (/System/Volumes/Data/mesos/work_dir/slaves/412fde1c-3e26-4c3d-b41e-bab008e2c85d-S9637/frameworks/1735e8a2-a1db-478c-8104-60c8b0af87dd-0196/executors/fcd59e7d-0eaa-4e79-a3dd-1eba2e7376f0/runs/30ba630e-86cc-4107-a518-430caed87a5e/workspace/open/src/hotspot/share/opto/memnode.cpp:3111), pid=38651, tid=27907
#  assert(shift_out >= 0) failed: must be positive
#
---------------  T H R E A D  ---------------

Current thread (0x000000013c821e10):  JavaThread "C2 CompilerThread0" daemon [_thread_in_native, id=27907, stack(0x000000016ebc0000,0x000000016edc3000) (2060K)]


Current CompileTask:
C2:74    8   !b  4       Test::mainTest (579 bytes)

Stack: [0x000000016ebc0000,0x000000016edc3000],  sp=0x000000016edbef80,  free space=2043k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
V  [libjvm.dylib+0x11216a0]  VMError::report_and_die(int, char const*, char const*, char*, Thread*, unsigned char*, void*, void*, char const*, int, unsigned long)+0x564  (memnode.cpp:3111)
V  [libjvm.dylib+0x1121ec0]  VMError::report_and_die(Thread*, unsigned int, unsigned char*, void*, void*)+0x0
V  [libjvm.dylib+0x549c9c]  print_error_for_unit_test(char const*, char const*, char*)+0x0
V  [libjvm.dylib+0xd306ac]  MergePrimitiveArrayStores::is_con_RShift(Node const*, Node const*&, int&)+0x1e8
V  [libjvm.dylib+0xd2fcfc]  MergePrimitiveArrayStores::is_adjacent_input_pair(Node const*, Node const*, int) const+0x64
V  [libjvm.dylib+0xd2fae0]  MergePrimitiveArrayStores::is_adjacent_pair(StoreNode const*, StoreNode const*) const+0x80
V  [libjvm.dylib+0xd2e988]  MergePrimitiveArrayStores::run()+0x114
V  [libjvm.dylib+0xd311dc]  StoreNode::Ideal(PhaseGVN*, bool)+0x504
V  [libjvm.dylib+0xe695bc]  PhaseIterGVN::transform_old(Node*)+0x164
V  [libjvm.dylib+0xe68a98]  PhaseIterGVN::optimize()+0xf8
V  [libjvm.dylib+0x4b653c]  Compile::process_for_post_loop_opts_igvn(PhaseIterGVN&)+0x138
V  [libjvm.dylib+0x4b198c]  Compile::Optimize()+0x9b8
V  [libjvm.dylib+0x4afdd0]  Compile::Compile(ciEnv*, ciMethod*, int, Options, DirectiveSet*)+0x1238
V  [libjvm.dylib+0x379b7c]  C2Compiler::compile_method(ciEnv*, ciMethod*, int, bool, DirectiveSet*)+0x1e0
V  [libjvm.dylib+0x4ce1ec]  CompileBroker::invoke_compiler_on_method(CompileTask*)+0x868
V  [libjvm.dylib+0x4cd61c]  CompileBroker::compiler_thread_loop()+0x348
V  [libjvm.dylib+0x88eb5c]  JavaThread::thread_main_inner()+0x1dc
V  [libjvm.dylib+0x1062c2c]  Thread::call_run()+0xf4
V  [libjvm.dylib+0xe1039c]  thread_native_entry(Thread*)+0x138
C  [libsystem_pthread.dylib+0x6f94]  _pthread_start+0x88
Lock stack of current Java thread (top to bottom):

Comments
Changeset: 3d11692b Author: Emanuel Peter <epeter@openjdk.org> Date: 2024-04-30 16:15:07 +0000 URL: https://git.openjdk.org/jdk/commit/3d11692bf369af951867209962e8bf5886d1655f
30-04-2024

A pull request was submitted for review. URL: https://git.openjdk.org/jdk/pull/19001 Date: 2024-04-29 15:43:06 +0000
29-04-2024

Simplified it even further: class Test { static long val; static int iArrFld[] = new int[10]; static void test() { iArrFld[0] = (int)(val >> -1); iArrFld[1] = (int)(val >> -1); } public static void main(String[] strArr) { for (int i = 0; i < 10_000; i++) { test(); } } } The issue is that negative shift leads to an assert.
29-04-2024

Thanks [~chagedorn] for reducing the test: Test.java ./java -Xcomp -XX:CompileOnly=Test::* Test.java
29-04-2024

ILW = Assertion failure in code merging stores, multiple fuzzer issues, disable compilation of affected method = HLM = P3
29-04-2024

Regression after JDK-8318446
29-04-2024