JDK-8266576 : dynamicArchive/ParallelLambdaLoadTest.java crashes with "assert(is_instance(java_string)) failed: must be java_string"
  • Type: Bug
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 17
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • Submitted: 2021-05-05
  • Updated: 2021-05-11
  • Resolved: 2021-05-08
Related Reports
Duplicate :  
Duplicate :  
Relates :  
Relates :  
Relates :  
Relates :  
Description
# To suppress the following error report, specify this argument
# after -XX: or in .hotspotrc:  SuppressErrorAt=\\classfile/javaClasses.inline.hpp:60
#
# A fatal error has been detected by the Java Runtime Environment:
#
#  Internal Error (t:\\workspace\\open\\src\\hotspot\\share\\classfile/javaClasses.inline.hpp:60), pid=20788, tid=67352
#  assert(is_instance(java_string)) failed: must be java_string
#
# JRE version: Java(TM) SE Runtime Environment (17.0+21) (fastdebug build 17-ea+21-LTS-1861)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (fastdebug 17-ea+21-LTS-1861, mixed mode, sharing, tiered, compressed oops, compressed class ptrs, g1 gc, windows-amd64)
# Core dump will be written. Default location: T:\\testoutput\\test-support\\jtreg_open_test_hotspot_jtreg_hotspot_tier2_runtime\\scratch\\4\\hs_err_pid20788.mdmp
#

Stack: [0x000000562b300000,0x000000562b400000]
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
V  [jvm.dll+0xacde41]  os::platform_print_native_stack+0xf1  (os_windows_x86.cpp:235)
V  [jvm.dll+0xcf0707]  VMError::report+0xfc7  (vmError.cpp:739)
V  [jvm.dll+0xcf208e]  VMError::report_and_die+0x7fe  (vmError.cpp:1549)
V  [jvm.dll+0xcf27a4]  VMError::report_and_die+0x64  (vmError.cpp:1330)
V  [jvm.dll+0x4ce687]  report_vm_error+0xb7  (debug.cpp:282)
V  [jvm.dll+0x652b46]  java_lang_String::value+0x36  (javaClasses.inline.hpp:60)
V  [jvm.dll+0x6afd94]  java_lang_String::as_utf8_string+0x14  (javaClasses.cpp:658)
V  [jvm.dll+0x8e9489]  LambdaFormInvokers::regenerate_holder_classes+0x4e9  (lambdaFormInvokers.cpp:115)
V  [jvm.dll+0x54f5ab]  DynamicArchive::dump+0x6b  (dynamicArchive.cpp:373)
V  [jvm.dll+0x6a9850]  before_exit+0x620  (java.cpp:508)
V  [jvm.dll+0xc78fdd]  Threads::destroy_vm+0x3ad  (thread.cpp:3395)
V  [jvm.dll+0x74123c]  jni_DestroyJavaVM+0xac  (jni.cpp:3746)
C  [jli.dll+0x5317]  JavaMain+0x18b  (java.c:558)
C  [ucrtbase.dll+0x2268a]
C  [KERNEL32.DLL+0x17974]
C  [ntdll.dll+0x5a2f1]

Comments
The bug 8255493 fix was backed out and will be redone.
08-05-2021

When the following is integrated: JDK-8266765 [BACKOUT] JDK-8255493 Support for pre-generated java.lang.invoke classes in CDS dynamic archive and we have verified that the failures associated with this bug stop, we can close this issue as a duplicate of JDK-8266765.
07-05-2021

I think the problem is we are invoking Java code too late in the VM lifecycle. The VM is already being shut down. It's not safe to execute Java code: V [jvm.dll+0x8e9489] LambdaFormInvokers::regenerate_holder_classes+0x4e9 (lambdaFormInvokers.cpp:115) V [jvm.dll+0x54f5ab] DynamicArchive::dump+0x6b (dynamicArchive.cpp:373) V [jvm.dll+0x6a9850] before_exit+0x620 (java.cpp:508) V [jvm.dll+0xc78fdd] Threads::destroy_vm+0x3ad (thread.cpp:3395) V [jvm.dll+0x74123c] jni_DestroyJavaVM+0xac (jni.cpp:3746) That's probably why we are getting an NullPointerException as the return value of a method that's declared to return an Object[] type. (This should never happen in a normal VM, but probably the VM state is already messed up). Instead, we should call it inside here: void MetaspaceShared::link_and_cleanup_shared_classes(TRAPS) { if (DynamicDumpSharedSpaces) { // regenerate lambdaform holder classes log_info(cds, dynamic)("Regenerate lambdaform holder classes ..."); LambdaFormInvokers::regenerate_holder_classes(CHECK); log_info(cds, dynamic)("Regenerate lambdaform holder classes ...done"); } the above is called before we execute Java shutdown hooks (from thread.cpp and jvm.cpp) so it's safe to execute Java code there.
05-05-2021

I can reproduce this on Linux/x64 by repeatedly running the test case inside gdb until the VM crashes [1]. It takes less than 20 runs for the fastdebug build. $ export JTREG_OUTPUT=/where/you/store/jtreg/output $ gdb $JAVA_HOME/bin/java --args -XX:+UnlockDiagnosticVMOptions \ -XX:SuppressErrorAt=/os.cpp:652 \ -XX:ArchiveClassesAtExit=$JTREG_OUTPUT/work/scratch/appcds-12h23m44s927.jsa \ -Xshare:auto -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xlog:cds+dynamic=info \ -Xbootclasspath/a:$JTREG_OUTPUT/work/scratch/WhiteBox.jar \ -cp $JTREG_OUTPUT/work/scratch/parallel_lambda.jar \ ParallelLambdaLoad (gdb) set pagination off (gdb) break exit Breakpoint 1 at 0xcafef00dbeef: file exit.c, line 99. (gdb) commands Type commands for breakpoint(s) 1, one per line. End with a line saying just "end". >run >end (gdb) run ... # Internal Error (/jdk2/gil/open/src/hotspot/share/classfile/javaClasses.inline.hpp:60), pid=13285, tid=13387 # assert(is_instance(java_string)) failed: must be java_string ... (gdb) up #7 0x00007ffff61d7311 in java_lang_String::as_utf8_string (java_string=..., length=@0x7ffff7fb5964: 32767) at /jdk2/gil/open/src/hotspot/share/oops/oopsHierarchy.hpp:90 90 oop(const oop& o) : _o(o._o) { register_if_checking(); } (gdb) info locals value = {<oop> = {_o = 0x8780c318}, <No data fields>} is_latin1 = <optimized out> (gdb) x/gx 0x8780c318 0x8780c318: 0x0000000000000001 (gdb) call pp(0x8780c318) "Executing pp" java.lang.NullPointerException {0x000000008780c318} - klass: 'java/lang/NullPointerException' - ---- fields (total size 6 words): - private transient 'depth' 'I' @12 2 - private transient 'backtrace' 'Ljava/lang/Object;' @16 a 'java/lang/Object'[6] {0x000000008780c348} (8780c348) - private 'detailMessage' 'Ljava/lang/String;' @20 NULL (0) - private 'cause' 'Ljava/lang/Throwable;' @24 a 'java/lang/NullPointerException'{0x000000008780c318} (8780c318) - private 'stackTrace' '[Ljava/lang/StackTraceElement;' @28 a 'java/lang/StackTraceElement'[0] {0x0000000087f144e0} (87f144e0) - private strict 'suppressedExceptions' 'Ljava/util/List;' @32 a 'java/util/Collections$EmptyList'{0x0000000087f14530} (87f14530) - private transient 'extendedMessageState' 'I' @36 1 - private transient 'extendedMessage' 'Ljava/lang/String;' @40 NULL (0) ======== [1] https://haaspors.github.io/tools/2015/01/21/gdb-run-until-crash.html
05-05-2021