JDK-8334421 : assert(!oldbox->is_unbalanced()) failed: this should not be called for unbalanced region
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 21.0.5,21.0.5-oracle,23,24
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2024-06-17
  • Updated: 2024-07-01
  • Resolved: 2024-06-25
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 JDK 24
21.0.5-oracleFixed 23Fixed 24 b04Fixed
Related Reports
Relates :  
Description
Test crashes with:
#
# A fatal error has been detected by the Java Runtime Environment:
#
#  Internal Error (/opt/mach5/mesos/work_dir/slaves/a4a7850a-7c35-410a-b879-d77fbb2f6087-S27961/frameworks/1735e8a2-a1db-478c-8104-60c8b0af87dd-0196/executors/92ce879a-aa7f-4da0-b681-ca2cd1754fa5/runs/d309a027-e69b-43a8-b3a3-b24fc4d77194/workspace/open/src/hotspot/share/opto/macro.cpp:1955), pid=1742462, tid=1750740
#  assert(!oldbox->is_unbalanced()) failed: this should not be called for unbalanced region
#
# JRE version: Java(TM) SE Runtime Environment (23.0+26) (fastdebug build 23-ea+26-2269)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (fastdebug 23-ea+26-2269, mixed mode, sharing, compressed oops, compressed class ptrs, g1 gc, linux-aarch64)
# Problematic frame:
# V  [libjvm.so+0x1145e3c]  PhaseMacroExpand::mark_eliminated_box(Node*, Node*)+0x93c
#
# 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/a4a7850a-7c35-410a-b879-d77fbb2f6087-S6402/frameworks/1735e8a2-a1db-478c-8104-60c8b0af87dd-0196/executors/96097c2c-ed26-4737-a4d7-5ffec0d18fbc/runs/2906419d-5aff-400b-82af-aa1027154d46/testoutput/test-support/jck_runtime_api_java_util/core.1742462)
#
# If you would like to submit a bug report, please visit:
#   https://bugreport.java.com/bugreport/crash.jsp
#

---------------  S U M M A R Y ------------

Command Line: --enable-preview -Djava.awt.headless=true -ea -esa -XX:CompileThreshold=100 -XX:+UnlockExperimentalVMOptions -XX:-TieredCompilation -XX:+EnableDynamicAgentLoading -Djdk.attach.allowAttachSelf=true -Djava.security.properties=/opt/mach5/mesos/work_dir/jib-master/install/jck/23/b12/extra/bundles/JCK-extra-23.zip/JCK-extra-23/extra.security.properties -XX:MaxRAMPercentage=6.25 -Djava.security.policy=/opt/mach5/mesos/work_dir/jib-master/install/jck/23/b12/bundles/JCK-runtime-23.jar/JCK-runtime-23/lib/jck.policy com.sun.jck.lib.multijvm.group.wrapper.ActiveMain -id 6 -host 100.103.48.193 -port 42419 -idleTimeout 1200000 -testTimeout 6000000

Host: ol9-aarch64-770816, AArch64, 8 cores, 30G, Oracle Linux Server release 9.3
Time: Tue Jun 11 07:28:06 2024 UTC elapsed time: 1766.605202 seconds (0d 0h 29m 26s)

---------------  T H R E A D  ---------------

Current thread (0x0000ffff49fd8db0):  JavaThread "C2 CompilerThread2" daemon [_thread_in_native, id=1750740, stack(0x0000fffefeb84000,0x0000fffefed82000) (2040K)]


Current CompileTask:
C2:1766605 60172 %           javasoft.sqe.tests.api.java.util.Vector.SetSizeTests::Vector2034 @ 353 (499 bytes)

Stack: [0x0000fffefeb84000,0x0000fffefed82000],  sp=0x0000fffefed7cb70,  free space=2018k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
V  [libjvm.so+0x1145e3c]  PhaseMacroExpand::mark_eliminated_box(Node*, Node*)+0x93c  (macro.cpp:1955)
V  [libjvm.so+0x1146110]  PhaseMacroExpand::mark_eliminated_locking_nodes(AbstractLockNode*)+0x250
V  [libjvm.so+0x114cc58]  PhaseMacroExpand::eliminate_macro_nodes()+0xe8
V  [libjvm.so+0x8cd900]  Compile::Optimize()+0x7f0
V  [libjvm.so+0x8d07d8]  Compile::Compile(ciEnv*, ciMethod*, int, Options, DirectiveSet*)+0x1484
V  [libjvm.so+0x72cd80]  C2Compiler::compile_method(ciEnv*, ciMethod*, int, bool, DirectiveSet*)+0x17c
V  [libjvm.so+0x8dc4ec]  CompileBroker::invoke_compiler_on_method(CompileTask*)+0x7cc
V  [libjvm.so+0x8dd034]  CompileBroker::compiler_thread_loop()+0x514
V  [libjvm.so+0xd3fd0c]  JavaThread::thread_main_inner()+0xcc
V  [libjvm.so+0x15a3320]  Thread::call_run()+0xac
V  [libjvm.so+0x12f9d44]  thread_native_entry(Thread*)+0x130
C  [libc.so.6+0x806b8]  start_thread+0x2d8
Registers:
Comments
A pull request was submitted for review. URL: https://git.openjdk.org/jdk/pull/19931 Date: 2024-06-27 15:55:27 +0000
27-06-2024

Yes, I am backporting it into JDK 23. I waited results of high tiers testing in mach5 CI.
27-06-2024

[jdk21u-fix-request] Approval Request from Aleksey Shipilëv This is a fix for regression introduced by JDK-8324969. that is already backported to 21.0.5. This forces our hand for backporting it to 21u-dev now. Applies cleanly. Aggressive compiler testing is passing. The new regression test is not sensitive to the issue, alas. A usual medium risk for C2 backports.
27-06-2024

[~kvn], I assume you are pulling this into JDK 23? I am pulling this into 21.0.5 meanwhile.
27-06-2024

A pull request was submitted for review. URL: https://git.openjdk.org/jdk21u-dev/pull/795 Date: 2024-06-26 16:55:18 +0000
26-06-2024

Changeset: 9c89f086 Author: Vladimir Kozlov <kvn@openjdk.org> Date: 2024-06-25 16:04:03 +0000 URL: https://git.openjdk.org/jdk/commit/9c89f0861c1b6d25e1a7c3ac1add9a168d807788
25-06-2024

[~kvn], ah, very nice! :)
25-06-2024

A pull request was submitted for review. URL: https://git.openjdk.org/jdk/pull/19870 Date: 2024-06-24 23:22:34 +0000
24-06-2024

New regression test reproduced the failure.
24-06-2024

Thank you, [~thartmann] I finally built a test based on JCK test code which reproduced failure with -XX:-TieredCompilation. I will add it into patch and do testing.
24-06-2024

> [~thartmann] I have the fix which I am testing in mach5 now. But I need help with simplified reproducer based on SetSizeTests::Vector2034() code. [~kvn] Okay, we could also file a follow-up RFE for that and I can assign someone.
24-06-2024

Testing of patch is clean - no new failures.
24-06-2024

I am testing attached 8334421_v00.patch fix.
21-06-2024

[~thartmann] I have the fix which I am testing in mach5 now. But I need help with simplified reproducer based on SetSizeTests::Vector2034() code. It easy reproduced with attached replay_pid82505.log on macOS and linux-x86.
21-06-2024

Seems JDK-8324969 fix was not complete.
20-06-2024

Correction, there are non escaping objects. On back of loop new TestVector object could is created: TestVector vect = (TestVector)vg.nextVector(); while (vect != null) { ... vect = vg.nextVector(); } So we have Phi node which represent `vect` variable which does not escape. The assert happens for lock which is marked by EA (I see eliminate_lock_set_non_esc3 mark in LogCompilation output).
20-06-2024

Almost all methods in java.util.Vector class are synchronized. SetSizeTests::Vector2034() method has next repetitive pattern where size() and setSize() are synchronized: old_size = vect.size(); vect.setSize(vect.size()*2); if(vect.size() != old_size*2) { return Status.failed("Vector: "+vect+" size incorrectly changed after setSize(size()*2)"); } That is where a lot of locks/unlocks come from. And most of them coarsened (can be eliminated) because they are used for the same object `vect`. There are no nested locks or locks for not-escaping objects in the code.
18-06-2024

Thank you, [~thartmann] for instructions. I reproduced it and start working on it.
18-06-2024

I will look.
18-06-2024

I checked and the replay file triggers the compilation but does not reproduce the issue (same build, same architecture).
18-06-2024

Assert was added by JDK-8324969 in JDK 23. [~kvn] would you have time to work on this or should we assign someone else? ILW = Similar to JDK-8324969 = P3
18-06-2024

Again the issue with lock optimization and OSR compilation: C2:871165 73176 % javasoft.sqe.tests.api.java.util.Vector.SetSizeTests::Vector2034 @ 353 (499 bytes)
17-06-2024

[~lmesnik] Do you have replay file?
17-06-2024

jck test api/java_util/Vector/Sort.html failed with VM opts: '-ea -esa -XX:CompileThreshold=100 -XX:+UnlockExperimentalVMOptions -server -XX:-TieredCompilation' on linux-aarch64.
17-06-2024