JDK-8232120 : com/sun/jdi/InvokeTest fails with -Xcheck:jni: assert(k->is_instance_klass()) failed: cast to InstanceKlass
  • Type: Bug
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 14
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2019-10-10
  • Updated: 2019-10-17
  • Resolved: 2019-10-11
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 14
14 b19Fixed
Related Reports
Relates :  
Description
Reliably reproduces in jdk/jdk:

$ CONF=linux-x86_64-server-fastdebug make images run-test TEST=com/sun/jdi/InvokeTest.java TEST_VM_OPTS="-Xcheck:jni"

----------System.out:(35/1974)----------
vmOpts: '-Xmx512m -XX:MaxRAMPercentage=3 -Xcheck:jni -ea -esa'
javaOpts: ''
JVM version:14-internal
JDI version: 14.0
JVM description: Java Debug Interface (Reference Implementation) version 14.0 
Java Debug Wire Protocol (Reference Implementation) version 14.0
JVM Debug Interface version 14.0
JVM version 14-internal (OpenJDK 64-Bit Server VM, mixed mode, sharing)
WARNING in native method: JNI call made without checking exceptions when required to from CallStaticObjectMethod
WARNING: JNI local refs: 415, exceeds capacity: 35
Howdy!
WARNING: JNI local refs: 507, exceeds capacity: 33
# To suppress the following error report, specify this argument
# after -XX: or in .hotspotrc:  SuppressErrorAt=/instanceKlass.hpp:1019
#
# A fatal error has been detected by the Java Runtime Environment:
#
#  Internal Error (/home/shade/trunks/jdk-jdk/src/hotspot/share/oops/instanceKlass.hpp:1019), pid=20573, tid=20578
#  assert(k->is_instance_klass()) failed: cast to InstanceKlass
#
# JRE version: OpenJDK Runtime Environment (14.0) (fastdebug build 14-internal+0-adhoc.shade.jdk-jdk)
# Java VM: OpenJDK 64-Bit Server VM (fastdebug 14-internal+0-adhoc.shade.jdk-jdk, mixed mode, sharing, tiered, compressed oops, g1 gc, linux-amd64)
# Problematic frame:
# V  [libjvm.so+0xf2a46a]  jniCheck::validate_call(JavaThread*, _jclass*, _jmethodID*, _jobject*) [clone .constprop.77]+0x18a
#
# Core dump will be written. Default location: Core dumps may be processed with "/usr/share/apport/apport %p %s %c %d %P" (or dumping to /home/shade/trunks/jdk-jdk/build/linux-x86_64-server-fastdebug/test-support/jtreg_test_jdk_tier1/scratch/3/core.20573)
#
# An error report file with more information is saved as:
# /home/shade/trunks/jdk-jdk/build/linux-x86_64-server-fastdebug/test-support/jtreg_test_jdk_tier1/scratch/3/hs_err_pid20573.log
#
# If you would like to submit a bug report, please visit:
#   http://bugreport.java.com/bugreport/crash.jsp
#

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

Current thread (0x00007ff914025000):  JavaThread "main" [_thread_in_vm, id=32010, stack(0x00007ff91e2a3000,0x00007ff91e3a4000)]

Stack: [0x00007ff91e2a3000,0x00007ff91e3a4000],  sp=0x00007ff91e3a2390,  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+0xf2a46a]  jniCheck::validate_call(JavaThread*, _jclass*, _jmethodID*, _jobject*) [clone .constprop.77]+0x18a
V  [libjvm.so+0xf2ab41]  checked_jni_CallObjectMethodA+0xd1
C  [libjdwp.so+0x1cb96]  invoker_doInvoke+0xe66
C  [libjdwp.so+0x14c7d]  reportEvents.part.2+0xad
C  [libjdwp.so+0x1505a]  event_callback+0x1da
C  [libjdwp.so+0x17e58]  cbBreakpoint+0xc8
V  [libjvm.so+0x111dc78]  JvmtiExport::post_raw_breakpoint(JavaThread*, Method*, unsigned char*)+0x2a8
V  [libjvm.so+0xdee187]  InterpreterRuntime::_breakpoint(JavaThread*, Method*, unsigned char*)+0xc7
j  InvokeTarg.sayHi()V+0
j  InvokeTarg.main([Ljava/lang/String;)V+15
v  ~StubRoutines::call_stub
V  [libjvm.so+0xe0495c]  JavaCalls::call_helper(JavaValue*, methodHandle const&, JavaCallArguments*, Thread*)+0x71c
V  [libjvm.so+0xed1499]  jni_invoke_static(JNIEnv_*, JavaValue*, _jobject*, JNICallType, _jmethodID*, JNI_ArgumentPusher*, Thread*) [clone .isra.153] [clone .constprop.242]+0x2a9
V  [libjvm.so+0xeeea57]  jni_CallStaticVoidMethodV+0x197
V  [libjvm.so+0xf3e865]  checked_jni_CallStaticVoidMethod+0x185
C  [libjli.so+0x4d33]  JavaMain+0xbd3
C  [libjli.so+0x8239]  ThreadJavaMain+0x9

Comments
URL: https://hg.openjdk.java.net/jdk/jdk/rev/e43ac61b89ab User: coleenp Date: 2019-10-11 15:50:25 +0000
11-10-2019

[~coleenp] Not quite sure why this bug was moved from hotspot/runtime to hotspot/svc. If you're looking for a JDI/debugger subcat, then core-svc/debugger is the right place... Or since the fix is in src/hotspot/share/prims/jniCheck.cpp this should move back to hotspot/runtime.
11-10-2019

When we fix this, we'll add tier1 -Xcheck:jni testing to our tiered testing.
10-10-2019

I broke this test with JDK-8229900 when I added extra checking. There were other failures in the jdk tests so I missed this one.
10-10-2019

The jniCheck mechanisms are quite basic and may not work correctly when callbacks are involved, due to the nesting. The fact we crash here may indicate a problem in JDWP.
10-10-2019