JDK-8322996 : BoxLockNode creation fails with assert(reg < CHUNK_SIZE) failed: sanity
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 8,11,17,21,23
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2024-01-04
  • Updated: 2024-06-14
  • Resolved: 2024-01-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 21 JDK 23
21.0.5-oracleFixed 23 b08Fixed
Related Reports
Relates :  
Relates :  
Relates :  
Description
# Failure analysis
The synchronized statements result in BoxLockNodes in C2, which require a stack slot and corresponding RegMask. When there is no more space on the stack (or, rather, when the RegMask cannot represent the too large stack slot), the assert triggers.

# Original description
C2 fails to compile deeply nested synchronized statements (see also related javac bug JDK-8322992).

java -XX:CompileCommand=compileonly,C2Bug::* -XX:CompileCommand=quiet -XX:-TieredCompilation -Xcomp C2Bug.java

# A fatal error has been detected by the Java Runtime Environment:
#
#  Internal Error (/workspace/open/src/hotspot/share/opto/regmask.hpp:298), pid=3564487, tid=3564501
#  assert(reg < CHUNK_SIZE) failed: sanity
#
# JRE version: Java(TM) SE Runtime Environment (23.0+1) (fastdebug build 23-cpu+1-1)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (fastdebug 23-cpu+1-1, compiled mode, sharing, compressed oops, compressed class ptrs, g1 gc, linux-amd64)
# Problematic frame:
# V  [libjvm.so+0x124767b]  BoxLockNode::BoxLockNode(int)+0x86b

Current CompileTask:
C2:1461   82   !b        C2Bug::test (1909 bytes)

Stack: [0x00007fda0e5a5000,0x00007fda0e6a6000],  sp=0x00007fda0e6a2610,  free space=1013k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
V  [libjvm.so+0x124767b]  BoxLockNode::BoxLockNode(int)+0x86b  (regmask.hpp:298)
V  [libjvm.so+0xd981de]  GraphKit::shared_lock(Node*)+0x8e
V  [libjvm.so+0x150a0a6]  Parse::do_one_bytecode()+0x2ca6
V  [libjvm.so+0x14f54af]  Parse::do_one_block()+0x23f
V  [libjvm.so+0x14f6975]  Parse::do_all_blocks()+0x135
V  [libjvm.so+0x14fab3d]  Parse::Parse(JVMState*, ciMethod*, float)+0xb2d
V  [libjvm.so+0x840d29]  ParseGenerator::generate(JVMState*)+0x169
V  [libjvm.so+0x9f1b9e]  Compile::Compile(ciEnv*, ciMethod*, int, Options, DirectiveSet*)+0x163e
V  [libjvm.so+0x83e5d7]  C2Compiler::compile_method(ciEnv*, ciMethod*, int, bool, DirectiveSet*)+0x1e7
V  [libjvm.so+0x9fd92c]  CompileBroker::invoke_compiler_on_method(CompileTask*)+0x92c
V  [libjvm.so+0x9fe5b8]  CompileBroker::compiler_thread_loop()+0x468
V  [libjvm.so+0xeb8eec]  JavaThread::thread_main_inner()+0xcc
V  [libjvm.so+0x179e4d6]  Thread::call_run()+0xb6
V  [libjvm.so+0x14a87a7]  thread_native_entry(Thread*)+0x127
Comments
[jdk21u-fix-request] Approval Request from Martin Should get backported for parity with 21.0.5-oracle. Applies cleanly and tier 1-4 have passed.
14-06-2024

A pull request was submitted for review. URL: https://git.openjdk.org/jdk21u-dev/pull/698 Date: 2024-06-12 10:09:54 +0000
12-06-2024

Changeset: 69586e7b Author: Daniel Lundén <dlunden@openjdk.org> Committer: Roberto Castañeda Lozano <rcastanedalo@openjdk.org> Date: 2024-01-29 09:14:26 +0000 URL: https://git.openjdk.org/jdk/commit/69586e7bdffe1a840c3a86e6ec83568de24c6fe5
29-01-2024

FTR, I found this (and also javac bug JDK-8322992) when reducing a test for JDK-8310844.
18-01-2024

A pull request was submitted for review. URL: https://git.openjdk.org/jdk/pull/17370 Date: 2024-01-11 10:19:12 +0000
11-01-2024

ILW = Assert during compilation due to large stack slot index of monitor, edge case and old issue but reproducible with simple test, disable compilation of affected method = HLM = P3
04-01-2024