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