JDK-8285301 : C2: assert(!requires_atomic_access) failed: can't ensure atomicity
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 17,18,19
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2022-04-17
  • Updated: 2022-06-21
  • Resolved: 2022-04-29
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 17 JDK 19
17.0.5-oracleFixed 19 b21Fixed
Related Reports
Relates :  
Description
A DESCRIPTION OF THE PROBLEM :
Run arbitrary program with -XX:+AlwaysAtomicAccesses, VM crashes.

Reproduce:
$ java -Xcomp -XX:+UnlockExperimentalVMOptions -XX:+AlwaysAtomicAccesses -version
#
# A fatal error has been detected by the Java Runtime Environment:
#
#  Internal Error (/home/jiahx/jdk_source/jdk17u/src/hotspot/share/gc/shared/c2/barrierSetC2.cpp:159), pid=6272, tid=6286
#  assert(!requires_atomic_access) failed: can't ensure atomicity
#
# JRE version: OpenJDK Runtime Environment (17.0.3) (fastdebug build 17.0.3-internal+0-adhoc.jiahx.jdk17u)
# Java VM: OpenJDK 64-Bit Server VM (fastdebug 17.0.3-internal+0-adhoc.jiahx.jdk17u, compiled mode, sharing, tiered, compressed oops, compressed class ptrs, g1 gc, linux-amd64)
# Problematic frame:
# V  [libjvm.so+0x5f4029]  BarrierSetC2::load_at_resolved(C2Access&, Type const*) const+0x139
#
# No core dump will be written. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
#
---------------  T H R E A D  ---------------

Current thread (0x00007f267c3b9830):  JavaThread "C2 CompilerThread0" daemon [_thread_in_native, id=6286, stack(0x00007f2608196000,0x00007f2608297000)]


Current CompileTask:
C2:    975  477    b  4       java.lang.Thread::<init> (9 bytes)

Stack: [0x00007f2608196000,0x00007f2608297000],  sp=0x00007f2608292820,  free space=1010k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
V  [libjvm.so+0x5f4029]  BarrierSetC2::load_at_resolved(C2Access&, Type const*) const+0x139
V  [libjvm.so+0xb263f0]  G1BarrierSetC2::load_at_resolved(C2Access&, Type const*) const+0x130
V  [libjvm.so+0x5f625e]  BarrierSetC2::load_at(C2Access&, Type const*) const+0xfe
V  [libjvm.so+0xc79c7b]  GraphKit::access_load(Node*, Type const*, BasicType, unsigned long)+0xeb
V  [libjvm.so+0x10f47af]  LibraryCallKit::inline_native_currentThread()+0x1f
V  [libjvm.so+0x110c204]  LibraryIntrinsic::generate(JVMState*)+0x284
V  [libjvm.so+0xa94c76]  Parse::do_call()+0x4c6
V  [libjvm.so+0x1412f8f]  Parse::do_one_bytecode()+0x2b7f
V  [libjvm.so+0x14014e2]  Parse::do_one_block()+0x392
V  [libjvm.so+0x1402718]  Parse::do_all_blocks()+0x128
V  [libjvm.so+0x140676c]  Parse::Parse(JVMState*, ciMethod*, float)+0xc4c
V  [libjvm.so+0x7a9d9a]  ParseGenerator::generate(JVMState*)+0x8a
V  [libjvm.so+0xa94c76]  Parse::do_call()+0x4c6
V  [libjvm.so+0x1412f8f]  Parse::do_one_bytecode()+0x2b7f
V  [libjvm.so+0x14014e2]  Parse::do_one_block()+0x392
V  [libjvm.so+0x1402718]  Parse::do_all_blocks()+0x128
V  [libjvm.so+0x140676c]  Parse::Parse(JVMState*, ciMethod*, float)+0xc4c
V  [libjvm.so+0x7a9d9a]  ParseGenerator::generate(JVMState*)+0x8a
V  [libjvm.so+0xa94c76]  Parse::do_call()+0x4c6
V  [libjvm.so+0x1412f8f]  Parse::do_one_bytecode()+0x2b7f
V  [libjvm.so+0x14014e2]  Parse::do_one_block()+0x392
V  [libjvm.so+0x1402718]  Parse::do_all_blocks()+0x128
V  [libjvm.so+0x140676c]  Parse::Parse(JVMState*, ciMethod*, float)+0xc4c
V  [libjvm.so+0x7a9d9a]  ParseGenerator::generate(JVMState*)+0x8a
V  [libjvm.so+0x951ff4]  Compile::Compile(ciEnv*, ciMethod*, int, bool, bool, bool, bool, bool, DirectiveSet*)+0x1194
V  [libjvm.so+0x7a70ed]  C2Compiler::compile_method(ciEnv*, ciMethod*, int, bool, DirectiveSet*)+0x12d
V  [libjvm.so+0x95fd8a]  CompileBroker::invoke_compiler_on_method(CompileTask*)+0xa6a
V  [libjvm.so+0x960858]  CompileBroker::compiler_thread_loop()+0x438
V  [libjvm.so+0x17f2d3f]  JavaThread::thread_main_inner()+0x1df
V  [libjvm.so+0x17f7c18]  Thread::call_run()+0xf8
V  [libjvm.so+0x13beee4]  thread_native_entry(Thread*)+0x104


FREQUENCY : always



Comments
A pull request was submitted for review. URL: https://git.openjdk.org/jdk18u/pull/156 Date: 2022-06-21 07:20:29 +0000
21-06-2022

Fix Request (JDK 18u) Fixes an assert in C2. The fix is low risk but does not apply cleanly due to changes to surrounding code. Already tested and backported to Oracle JDK 17u.
21-06-2022

Fix request [17u] I backport this for parity with 17.0.5-oracle. A defensive fix for C2 we should take. I had to do one simple resolve. Tests pass, unfortunately also without the fix. SAP nightly testing passed.
10-06-2022

A pull request was submitted for review. URL: https://git.openjdk.java.net/jdk17u-dev/pull/454 Date: 2022-06-09 10:13:26 +0000
09-06-2022

Changeset: 0a4a6403 Author: Tobias Hartmann <thartmann@openjdk.org> Date: 2022-04-29 06:12:43 +0000 URL: https://git.openjdk.java.net/jdk/commit/0a4a6403bbdfa7a9f632dbf625435d9aaf04074c
29-04-2022

A pull request was submitted for review. URL: https://git.openjdk.java.net/jdk/pull/8422 Date: 2022-04-27 10:25:36 +0000
27-04-2022

I also hit this: # A fatal error has been detected by the Java Runtime Environment: # # Internal Error (/oracle/jdk2/open/src/hotspot/share/gc/shared/c2/barrierSetC2.cpp:173), pid=584115, tid=584130 # assert(!requires_atomic_access) failed: not yet supported Current CompileTask: C2: 4039 1804 !b 4 java.lang.invoke.DirectMethodHandle::makePreparedLambdaForm (798 bytes) Stack: [0x00007fdd5983a000,0x00007fdd5993b000], sp=0x00007fdd59936710, free space=1009k Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code) V [libjvm.so+0x707a14] BarrierSetC2::load_at_resolved(C2Access&, Type const*) const+0x3a4 V [libjvm.so+0xcaee8f] G1BarrierSetC2::load_at_resolved(C2Access&, Type const*) const+0xcf V [libjvm.so+0x705e8d] BarrierSetC2::load_at(C2Access&, Type const*) const+0xed V [libjvm.so+0x6561a5] ArrayCopyNode::load(BarrierSetC2*, PhaseGVN*, Node*&, MergeMemNode*, Node*, TypePtr const*, Type const*, BasicType)+0xb5 V [libjvm.so+0x65a52f] ArrayCopyNode::array_copy_forward(PhaseGVN*, bool, Node*&, Node*, TypePtr const*, TypePtr const*, Node*, Node*, Node*, Node*, BasicType, Type const*, int)+0x29f V [libjvm.so+0x65dbc5] ArrayCopyNode::Ideal(PhaseGVN*, bool)+0x1095 V [libjvm.so+0x16daeb5] PhaseGVN::transform_no_reclaim(Node*)+0x25 V [libjvm.so+0x1323213] LibraryCallKit::inline_array_copyOf(bool)+0x6e3 V [libjvm.so+0x1341fa2] LibraryIntrinsic::generate(JVMState*)+0x302 V [libjvm.so+0xc118a8] Parse::do_call()+0x378 V [libjvm.so+0x1694a68] Parse::do_one_block()+0xa88 V [libjvm.so+0x1695a27] Parse::do_all_blocks()+0x137 V [libjvm.so+0x169a8b6] Parse::Parse(JVMState*, ciMethod*, float)+0xb96 V [libjvm.so+0x8c9b60] ParseGenerator::generate(JVMState*)+0x110 V [libjvm.so+0xc118a8] Parse::do_call()+0x378 V [libjvm.so+0x1694a68] Parse::do_one_block()+0xa88 V [libjvm.so+0x1695a27] Parse::do_all_blocks()+0x137 V [libjvm.so+0x169a8b6] Parse::Parse(JVMState*, ciMethod*, float)+0xb96 V [libjvm.so+0x8c9b60] ParseGenerator::generate(JVMState*)+0x110 V [libjvm.so+0xab463a] Compile::Compile(ciEnv*, ciMethod*, int, Options, DirectiveSet*)+0x135a V [libjvm.so+0x8c75a3] C2Compiler::compile_method(ciEnv*, ciMethod*, int, bool, DirectiveSet*)+0x683 V [libjvm.so+0xac4407] CompileBroker::invoke_compiler_on_method(CompileTask*)+0xc97 V [libjvm.so+0xac52e8] CompileBroker::compiler_thread_loop()+0x728 V [libjvm.so+0x1969aaa] JavaThread::thread_main_inner()+0x25a V [libjvm.so+0x1974dd0] Thread::call_run()+0x100 V [libjvm.so+0x164d9e4] thread_native_entry(Thread*)+0x104 # A fatal error has been detected by the Java Runtime Environment: # # Internal Error (/oracle/jdk2/open/src/hotspot/share/gc/shared/c2/barrierSetC2.cpp:107), pid=588745, tid=588761 # assert(!requires_atomic_access) failed: not yet supported Current CompileTask: C2: 3818 1804 !b 4 java.lang.invoke.DirectMethodHandle::makePreparedLambdaForm (798 bytes) Stack: [0x00007f740fbfc000,0x00007f740fcfd000], sp=0x00007f740fcf8740, free space=1009k Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code) V [libjvm.so+0x707554] BarrierSetC2::store_at_resolved(C2Access&, C2AccessValue&) const+0x344 V [libjvm.so+0x705b7d] BarrierSetC2::store_at(C2Access&, C2AccessValue&) const+0xed V [libjvm.so+0x656318] ArrayCopyNode::store(BarrierSetC2*, PhaseGVN*, Node*&, MergeMemNode*, Node*, TypePtr const*, Node*, Type const*, BasicType)+0xf8 V [libjvm.so+0x65a553] ArrayCopyNode::array_copy_forward(PhaseGVN*, bool, Node*&, Node*, TypePtr const*, TypePtr const*, Node*, Node*, Node*, Node*, BasicType, Type const*, int)+0x2c3 V [libjvm.so+0x65dbc5] ArrayCopyNode::Ideal(PhaseGVN*, bool)+0x1095 V [libjvm.so+0x16daeb5] PhaseGVN::transform_no_reclaim(Node*)+0x25 V [libjvm.so+0x1323213] LibraryCallKit::inline_array_copyOf(bool)+0x6e3 V [libjvm.so+0x1341fa2] LibraryIntrinsic::generate(JVMState*)+0x302 V [libjvm.so+0xc118a8] Parse::do_call()+0x378 V [libjvm.so+0x1694a68] Parse::do_one_block()+0xa88 V [libjvm.so+0x1695a27] Parse::do_all_blocks()+0x137 V [libjvm.so+0x169a8b6] Parse::Parse(JVMState*, ciMethod*, float)+0xb96 V [libjvm.so+0x8c9b60] ParseGenerator::generate(JVMState*)+0x110 V [libjvm.so+0xc118a8] Parse::do_call()+0x378 V [libjvm.so+0x1694a68] Parse::do_one_block()+0xa88 V [libjvm.so+0x1695a27] Parse::do_all_blocks()+0x137 V [libjvm.so+0x169a8b6] Parse::Parse(JVMState*, ciMethod*, float)+0xb96 V [libjvm.so+0x8c9b60] ParseGenerator::generate(JVMState*)+0x110 V [libjvm.so+0xab463a] Compile::Compile(ciEnv*, ciMethod*, int, Options, DirectiveSet*)+0x135a V [libjvm.so+0x8c75a3] C2Compiler::compile_method(ciEnv*, ciMethod*, int, bool, DirectiveSet*)+0x683 V [libjvm.so+0xac4407] CompileBroker::invoke_compiler_on_method(CompileTask*)+0xc97 V [libjvm.so+0xac52e8] CompileBroker::compiler_thread_loop()+0x728 V [libjvm.so+0x1969aaa] JavaThread::thread_main_inner()+0x25a V [libjvm.so+0x1974dd0] Thread::call_run()+0x100 V [libjvm.so+0x164d9e4] thread_native_entry(Thread*)+0x104
26-04-2022

I think the assert is too strong, require_atomic_access should only affect T_LONG/T_DOUBLE accesses and the one emitted by LibraryCallKit::inline_native_currentThread is T_OBJECT.
26-04-2022

ILW = JVM crash, debug build with experimental option enabled, do not enable the option = HLL = P4
25-04-2022

Fair enough, [~coleenp] feel free to unassign and change subcomponent to 'compiler' if you agree.
22-04-2022

Hi Sorry I didn't look at this yesterday. As David said, I didn't do the compiler part of the change that caused this problem, so I'd like to reassign it back to the compiler group.
22-04-2022

It is definitely a compiler issue even though runtime took point on the other enhancement - Tom Rodriguez provided some of the changes.
22-04-2022

Note that the issue can also be reproduced in JDK 19 (b18).
21-04-2022

Moving issue to runtime team, since it owns the enhancement (JDK-8244997) that introduced the failing assertion. Please feel free to send back to compiler (or gc) if you disagree.
21-04-2022

Issue is reproduced. java -Xcomp -XX:+UnlockExperimentalVMOptions -XX:+AlwaysAtomicAccesses -version leads to crash in JDK 17 and 18 fastdebug builds. OS: Windows 10 JDK 17.0.3: Fail JDK 18.0.1 : Fail ILW = assert with non-default flag value; medium; no workaround if non-default flags are really needed = MMH = P3 Moving it to dev team for further analysis.
21-04-2022