This happens only with JDK 16. Related code has been changed in JDK 17 and the crash no longer happens.
$ java -version
java version "16" 2021-03-16
Java(TM) SE Runtime Environment (build 16+36-2231)
Java HotSpot(TM) 64-Bit Server VM (build 16+36-2231, mixed mode, sharing)
$ java -Xshare:dump -XX:DumpLoadedClassList=foo.txt
#
# A fatal error has been detected by the Java Runtime Environment:
#
# SIGSEGV (0xb) at pc=0x00007f4a2417bd80, pid=9476, tid=9477
#
# JRE version: Java(TM) SE Runtime Environment (16.0+36) (build 16+36-2231)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (16+36-2231, interpreted mode, tiered, compressed oops, g1 gc, linux-amd64)
# Problematic frame:
# V [libjvm.so+0x7d7d80] InstanceKlass::print_class_load_logging(ClassLoaderData*, ModuleEntry const*, ClassFileStream const*) const+0x850
#
...
Stack: [0x00007f4a256db000,0x00007f4a257dc000], sp=0x00007f4a257d9370, free space=1016k
Native frames: (J=compiled Java code, A=aot compiled Java code, j=interpreted, Vv=VM code, C=native code)
V [libjvm.so+0x7d7d80] InstanceKlass::print_class_load_logging(ClassLoaderData*, ModuleEntry const*, ClassFileStream const*) const+0x850
V [libjvm.so+0x554c1e] ClassFileParser::fill_instance_klass(InstanceKlass*, bool, ClassInstanceInfo const&, Thread*)+0xb9e
V [libjvm.so+0x554fd2] ClassFileParser::create_instance_klass(bool, ClassInstanceInfo const&, Thread*)+0x72
V [libjvm.so+0xa2080c] KlassFactory::create_from_stream(ClassFileStream*, Symbol*, ClassLoaderData*, ClassLoadInfo const&, Thread*)+0x1cc
V [libjvm.so+0xa2441e] LambdaFormInvokers::reload_class(char*, ClassFileStream&, Thread*)+0x7e
V [libjvm.so+0xa248d2] LambdaFormInvokers::regenerate_holder_classes(Thread*)+0x3d2
V [libjvm.so+0xb5adaf] MetaspaceShared::preload_and_dump(Thread*)+0x18f
V [libjvm.so+0xd846fb] Threads::create_vm(JavaVMInitArgs*, bool*)+0xaeb
V [libjvm.so+0x890191] JNI_CreateJavaVM+0x51
C [libjli.so+0x39bf] JavaMain+0x8f
C [libjli.so+0x7ec9] ThreadJavaMain+0x9
$ java -version
java version "16" 2021-03-16
Java(TM) SE Runtime Environment (build 16+36-2231)
Java HotSpot(TM) 64-Bit Server VM (build 16+36-2231, mixed mode, sharing)
$ java -Xshare:dump -XX:DumpLoadedClassList=foo.txt
#
# A fatal error has been detected by the Java Runtime Environment:
#
# SIGSEGV (0xb) at pc=0x00007f4a2417bd80, pid=9476, tid=9477
#
# JRE version: Java(TM) SE Runtime Environment (16.0+36) (build 16+36-2231)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (16+36-2231, interpreted mode, tiered, compressed oops, g1 gc, linux-amd64)
# Problematic frame:
# V [libjvm.so+0x7d7d80] InstanceKlass::print_class_load_logging(ClassLoaderData*, ModuleEntry const*, ClassFileStream const*) const+0x850
#
...
Stack: [0x00007f4a256db000,0x00007f4a257dc000], sp=0x00007f4a257d9370, free space=1016k
Native frames: (J=compiled Java code, A=aot compiled Java code, j=interpreted, Vv=VM code, C=native code)
V [libjvm.so+0x7d7d80] InstanceKlass::print_class_load_logging(ClassLoaderData*, ModuleEntry const*, ClassFileStream const*) const+0x850
V [libjvm.so+0x554c1e] ClassFileParser::fill_instance_klass(InstanceKlass*, bool, ClassInstanceInfo const&, Thread*)+0xb9e
V [libjvm.so+0x554fd2] ClassFileParser::create_instance_klass(bool, ClassInstanceInfo const&, Thread*)+0x72
V [libjvm.so+0xa2080c] KlassFactory::create_from_stream(ClassFileStream*, Symbol*, ClassLoaderData*, ClassLoadInfo const&, Thread*)+0x1cc
V [libjvm.so+0xa2441e] LambdaFormInvokers::reload_class(char*, ClassFileStream&, Thread*)+0x7e
V [libjvm.so+0xa248d2] LambdaFormInvokers::regenerate_holder_classes(Thread*)+0x3d2
V [libjvm.so+0xb5adaf] MetaspaceShared::preload_and_dump(Thread*)+0x18f
V [libjvm.so+0xd846fb] Threads::create_vm(JavaVMInitArgs*, bool*)+0xaeb
V [libjvm.so+0x890191] JNI_CreateJavaVM+0x51
C [libjli.so+0x39bf] JavaMain+0x8f
C [libjli.so+0x7ec9] ThreadJavaMain+0x9
- duplicates
-
JDK-8267345 VM crashes during dumping classlist with -Xshare:dump option
- Resolved
- relates to
-
JDK-8247536 Support for pre-generated java.lang.invoke classes in CDS static archive
- Resolved