8304147: JVM crash during shutdown when dumping dynamic archive

Reviewed-by: ccheung, matsaave, coleenp
This commit is contained in:
David Holmes 2023-03-27 22:05:23 +00:00
parent 554bccf046
commit 63ce88b5fb
7 changed files with 169 additions and 56 deletions

View file

@ -2023,22 +2023,11 @@ bool JavaThread::sleep(jlong millis) {
void JavaThread::invoke_shutdown_hooks() {
HandleMark hm(this);
// We could get here with a pending exception, if so clear it now or
// it will cause MetaspaceShared::link_shared_classes to
// fail for dynamic dump.
// We could get here with a pending exception, if so clear it now.
if (this->has_pending_exception()) {
this->clear_pending_exception();
}
#if INCLUDE_CDS
// Link all classes for dynamic CDS dumping before vm exit.
// Same operation is being done in JVM_BeforeHalt for handling the
// case where the application calls System.exit().
if (DynamicArchive::should_dump_at_vm_exit()) {
DynamicArchive::prepare_for_dump_at_exit();
}
#endif
EXCEPTION_MARK;
Klass* shutdown_klass =
SystemDictionary::resolve_or_null(vmSymbols::java_lang_Shutdown(),