JDK-8252871 : fatal error: must own lock JvmtiThreadState_lock
  • Type: Bug
  • Component: hotspot
  • Sub-Component: jvmti
  • Affected Version: 16
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2020-09-07
  • Updated: 2024-11-22
  • Resolved: 2020-09-08
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 16
16 b15Fixed
Related Reports
Relates :  
Description
Test: com/sun/jdi/PopAndStepTest.java

#
# A fatal error has been detected by the Java Runtime Environment:
#
#  Internal Error (/opt/mach5/mesos/work_dir/slaves/4728e7c1-7e67-490e-be0f-6bbf2a2f33db-S100/frameworks/1735e8a2-a1db-478c-8104-60c8b0af87dd-0196/executors/419c9ef8-384e-4690-916a-0e9af51ffb84/runs/9e754de0-a82a-4e4f-b949-b624d61cf513/workspace/open/src/hotspot/share/runtime/mutexLocker.cpp:191), pid=899, tid=902
#  fatal error: must own lock JvmtiThreadState_lock
#
# JRE version: Java(TM) SE Runtime Environment (16.0) (fastdebug build 16-internal+0-2020-09-07-0702453.david.holmes.jdk-dev2.git)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (fastdebug 16-internal+0-2020-09-07-0702453.david.holmes.jdk-dev2.git, mixed mode, sharing, tiered, z gc, linux-amd64)
# Problematic frame:
# V  [libjvm.so+0x13fbf09]  assert_lock_strong(Mutex const*)+0x49
#
# 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/4728e7c1-7e67-490e-be0f-6bbf2a2f33db-S193/frameworks/1735e8a2-a1db-478c-8104-60c8b0af87dd-0196/executors/584af2b0-a124-4132-87f6-f9f2b592c613/runs/d10f81a2-b73f-4054-a023-51540f7708ae/testoutput/test-support/jtreg_open_test_jdk_jdk_jdi/scratch/2/core.899)
#
# 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: -Xmx512m -XX:MaxRAMPercentage=6 -Djava.io.tmpdir=/opt/mach5/mesos/work_dir/slaves/4728e7c1-7e67-490e-be0f-6bbf2a2f33db-S193/frameworks/1735e8a2-a1db-478c-8104-60c8b0af87dd-0196/executors/584af2b0-a124-4132-87f6-f9f2b592c613/runs/d10f81a2-b73f-4054-a023-51540f7708ae/testoutput/test-support/jtreg_open_test_jdk_jdk_jdi/tmp -ea -esa -XX:+CreateCoredumpOnCrash -XX:+UseZGC -Xdebug -Xrunjdwp:transport=dt_socket,address=localhost:57155,suspend=y PopAndStepTarg

Host: ol7-build-test-469105, AMD EPYC 7551 32-Core Processor, 8 cores, 31G, Oracle Linux Server release 7.8
Time: Mon Sep  7 07:38:25 2020 UTC elapsed time: 0.328173 seconds (0d 0h 0m 0s)

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

Current thread (0x00007f363c033610):  JavaThread "main" [_thread_in_vm, id=902, stack(0x00007f36461cc000,0x00007f36462cd000)]

Stack: [0x00007f36461cc000,0x00007f36462cd000],  sp=0x00007f36462cb070,  free space=1020k
Native frames: (J=compiled Java code, A=aot compiled Java code, j=interpreted, Vv=VM code, C=native code)
V  [libjvm.so+0x13fbf09]  assert_lock_strong(Mutex const*)+0x49
V  [libjvm.so+0x11388d6]  JvmtiEventController::set_frame_pop(JvmtiEnvThreadState*, JvmtiFramePop)+0x26
V  [libjvm.so+0x112255a]  SetFramePopClosure::do_thread(Thread*)+0x13a
V  [libjvm.so+0xca5c5b]  HandshakeOperation::do_handshake(JavaThread*)+0x4b
V  [libjvm.so+0xca6d33]  HandshakeState::process_self_inner()+0x223
V  [libjvm.so+0x15f3fdd]  SafepointMechanism::block_if_requested_slow(JavaThread*)+0xcd
V  [libjvm.so+0x1155f76]  JvmtiRawMonitor::simple_wait(Thread*, long)+0x366
V  [libjvm.so+0x1156b3f]  JvmtiRawMonitor::raw_wait(long, Thread*)+0x6f
V  [libjvm.so+0x111d07a]  JvmtiEnv::RawMonitorWait(JvmtiRawMonitor*, long)+0x3a
C  [libjdwp.so+0x28f85]  debugMonitorWait+0x25
C  [libjdwp.so+0x22772]  popFrameCompleteEvent+0x92
C  [libjdwp.so+0x244ff]  threadControl_onEventHandlerEntry+0x21f
C  [libjdwp.so+0x1596b]  event_callback+0xcb
C  [libjdwp.so+0x18b45]  cbSingleStep+0xc5
V  [libjvm.so+0x1145f5d]  JvmtiExport::post_single_step(JavaThread*, Method*, unsigned char*)+0x1fd
V  [libjvm.so+0x114625e]  JvmtiExport::at_single_stepping_point(JavaThread*, Method*, unsigned char*)+0x9e
V  [libjvm.so+0xd7cf51]  InterpreterRuntime::at_safepoint(JavaThread*)+0x171
j  PopAndStepTarg.main([Ljava/lang/String;)V+17
v  ~StubRoutines::call_stub
V  [libjvm.so+0xd956ca]  JavaCalls::call_helper(JavaValue*, methodHandle const&, JavaCallArguments*, Thread*)+0x62a
V  [libjvm.so+0xeb8745]  jni_invoke_static(JNIEnv_*, JavaValue*, _jobject*, JNICallType, _jmethodID*, JNI_ArgumentPusher*, Thread*) [clone .isra.0] [clone .constprop.1]+0x3e5
V  [libjvm.so+0xebe270]  jni_CallStaticVoidMethod+0x210
C  [libjli.so+0x496e]  JavaMain+0xc1e
C  [libjli.so+0x7759]  ThreadJavaMain+0x9

Crash occurs after the fix for JDK-8242427.
Comments
Changeset: 704f784c Author: Robbin Ehn <rehn@openjdk.org> Date: 2020-09-08 13:45:19 +0000 URL: https://git.openjdk.java.net/jdk/commit/704f784c
08-09-2020

I while testing was running I did a PR draft and then added the link. Skara doesn't link it until the PR is 'ready'.
08-09-2020

Checking is_locked() is not sufficient. Further this means the locking is broken as we should not be proxying locks during the handshake (that is equivalent to the old VMThread lock-sneaking hackery!). Either the lock must be acquired, as needed, during the actual handshake operation, or else we have to control things such that only the handshaker executes the operation after acquiring the lock prior to the handshake.
08-09-2020

https://github.com/openjdk/jdk/pull/60
07-09-2020

Running tests on: https://github.com/robehn/jdk/tree/8252871-wrong-assert Locally it passes.
07-09-2020

The wrong assert is used: assert_lock_strong checks if current thread is the owner, which is not always true during a handshake. We can only check lock->is_locked().
07-09-2020

I'll send out fix nowish :)
07-09-2020