Skip to content

Commit cdf9cd8

Browse files
committed
8255784: appcds/javaldr/ExceptionDuringDumpAtObjectsInitPhase.java test failed resulting in VM crash
Reviewed-by: ccheung, iklam
1 parent eab99f3 commit cdf9cd8

File tree

4 files changed

+19
-9
lines changed

4 files changed

+19
-9
lines changed

src/hotspot/share/memory/archiveUtils.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -323,8 +323,8 @@ void ArchiveUtils::log_to_classlist(BootstrapInfo* bootstrap_specifier, TRAPS) {
323323
void ArchiveUtils::check_for_oom(oop exception) {
324324
assert(exception != nullptr, "Sanity check");
325325
if (exception->is_a(SystemDictionary::OutOfMemoryError_klass())) {
326-
vm_exit_during_cds_dumping(
327-
err_msg("Out of memory. Please run with a larger Java heap, current MaxHeapSize = " SIZE_FORMAT "M",
328-
MaxHeapSize/M));
326+
vm_direct_exit(-1,
327+
err_msg("Out of memory. Please run with a larger Java heap, current MaxHeapSize = "
328+
SIZE_FORMAT "M", MaxHeapSize/M));
329329
}
330330
}

src/hotspot/share/memory/heapShared.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,9 @@ oop HeapShared::archive_heap_object(oop obj, Thread* THREAD) {
206206
log_error(cds, heap)(
207207
"Cannot allocate space for object " PTR_FORMAT " in archived heap region",
208208
p2i(obj));
209-
vm_exit(1);
209+
vm_direct_exit(-1,
210+
err_msg("Out of memory. Please run with a larger Java heap, current MaxHeapSize = "
211+
SIZE_FORMAT "M", MaxHeapSize/M));
210212
}
211213
return archived_oop;
212214
}
@@ -725,7 +727,7 @@ oop HeapShared::archive_reachable_objects_from(int level,
725727
// these objects that are referenced (directly or indirectly) by static fields.
726728
ResourceMark rm;
727729
log_error(cds, heap)("Cannot archive object of class %s", orig_obj->klass()->external_name());
728-
vm_exit(1);
730+
vm_direct_exit(1);
729731
}
730732

731733
// java.lang.Class instances cannot be included in an archived object sub-graph. We only support
@@ -735,7 +737,7 @@ oop HeapShared::archive_reachable_objects_from(int level,
735737
// object that is referenced (directly or indirectly) by static fields.
736738
if (java_lang_Class::is_instance(orig_obj)) {
737739
log_error(cds, heap)("(%d) Unknown java.lang.Class object is in the archived sub-graph", level);
738-
vm_exit(1);
740+
vm_direct_exit(1);
739741
}
740742

741743
oop archived_obj = find_archived_heap_object(orig_obj);
@@ -771,7 +773,7 @@ oop HeapShared::archive_reachable_objects_from(int level,
771773
// We don't know how to handle an object that has been archived, but some of its reachable
772774
// objects cannot be archived. Bail out for now. We might need to fix this in the future if
773775
// we have a real use case.
774-
vm_exit(1);
776+
vm_direct_exit(1);
775777
}
776778
}
777779

@@ -1031,7 +1033,7 @@ void HeapShared::init_subgraph_entry_fields(ArchivableStaticFieldInfo fields[],
10311033
ArchiveUtils::check_for_oom(PENDING_EXCEPTION); // exit on OOM
10321034
log_info(cds)("%s: %s", PENDING_EXCEPTION->klass()->external_name(),
10331035
java_lang_String::as_utf8_string(java_lang_Throwable::message(PENDING_EXCEPTION)));
1034-
vm_exit_during_initialization("VM exits due to exception, use -Xlog:cds,exceptions=trace for detail");
1036+
vm_direct_exit(-1, "VM exits due to exception, use -Xlog:cds,exceptions=trace for detail");
10351037
}
10361038
InstanceKlass* ik = InstanceKlass::cast(k);
10371039
assert(InstanceKlass::cast(ik)->is_shared_boot_class(),

src/hotspot/share/runtime/java.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -578,6 +578,13 @@ void vm_direct_exit(int code) {
578578
os::exit(code);
579579
}
580580

581+
void vm_direct_exit(int code, const char* message) {
582+
if (message != nullptr) {
583+
tty->print_cr("%s", message);
584+
}
585+
vm_direct_exit(code);
586+
}
587+
581588
void vm_perform_shutdown_actions() {
582589
if (is_init_completed()) {
583590
Thread* thread = Thread::current_or_null();

src/hotspot/share/runtime/java.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -35,6 +35,7 @@ extern void vm_exit(int code);
3535

3636
// Wrapper for ::exit()
3737
extern void vm_direct_exit(int code);
38+
extern void vm_direct_exit(int code, const char* message);
3839

3940
// Shutdown the VM but do not exit the process
4041
extern void vm_shutdown();

0 commit comments

Comments
 (0)