Skip to content

Commit 6e920fb

Browse files
author
David Holmes
committed
8372380: Make hs_err reporting more robust for unattached threads
Reviewed-by: shade, aboldtch, kevinw
1 parent c028369 commit 6e920fb

File tree

4 files changed

+11
-5
lines changed

4 files changed

+11
-5
lines changed

src/hotspot/share/compiler/compilationMemoryStatistic.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1010,8 +1010,10 @@ void CompilationMemoryStatistic::print_error_report(outputStream* st) {
10101010
oom_stats->print_peak_state_on(st);
10111011
st->cr();
10121012
}
1013-
st->print_cr("Compiler Memory Statistic, 10 most expensive compilations:");
1014-
print_all_by_size(st, false, false, 0, 10);
1013+
if (Thread::current_or_null_safe() != nullptr) {
1014+
st->print_cr("Compiler Memory Statistic, 10 most expensive compilations:");
1015+
print_all_by_size(st, false, false, 0, 10);
1016+
}
10151017
}
10161018

10171019
void CompilationMemoryStatistic::print_final_report(outputStream* st) {

src/hotspot/share/gc/g1/g1CollectedHeap.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2355,7 +2355,8 @@ static void print_region_type(outputStream* st, const char* type, uint count, bo
23552355
}
23562356

23572357
void G1CollectedHeap::print_heap_on(outputStream* st) const {
2358-
size_t heap_used = Heap_lock->owned_by_self() ? used() : used_unlocked();
2358+
size_t heap_used = (Thread::current_or_null_safe() != nullptr &&
2359+
Heap_lock->owned_by_self()) ? used() : used_unlocked();
23592360
st->print("%-20s", "garbage-first heap");
23602361
st->print(" total reserved %zuK, committed %zuK, used %zuK",
23612362
_hrm.reserved().byte_size()/K, capacity()/K, heap_used/K);

src/hotspot/share/gc/shared/gcLogPrecious.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include "runtime/mutex.hpp"
2626
#include "runtime/mutexLocker.hpp"
2727
#include "runtime/os.hpp"
28+
#include "runtime/thread.hpp"
2829
#include "utilities/ostream.hpp"
2930

3031
stringStream* GCLogPrecious::_lines = nullptr;
@@ -83,7 +84,8 @@ void GCLogPrecious::print_on_error(outputStream* st) {
8384
return;
8485
}
8586

86-
if (!_lock->try_lock_without_rank_check()) {
87+
if (Thread::current_or_null_safe() == nullptr ||
88+
!_lock->try_lock_without_rank_check()) {
8789
st->print_cr("<Skipped>\n");
8890
return;
8991
}

src/hotspot/share/utilities/vmError.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -664,6 +664,7 @@ void VMError::report(outputStream* st, bool _verbose) {
664664
BEGIN
665665
if (MemTracker::enabled() &&
666666
NmtVirtualMemory_lock != nullptr &&
667+
_thread != nullptr &&
667668
NmtVirtualMemory_lock->owned_by_self()) {
668669
// Manually unlock to avoid reentrancy due to mallocs in detailed mode.
669670
NmtVirtualMemory_lock->unlock();
@@ -1305,7 +1306,7 @@ void VMError::report(outputStream* st, bool _verbose) {
13051306
os::print_signal_handlers(st, buf, sizeof(buf));
13061307
st->cr();
13071308

1308-
STEP_IF("Native Memory Tracking", _verbose)
1309+
STEP_IF("Native Memory Tracking", _verbose && _thread != nullptr)
13091310
MemTracker::error_report(st);
13101311
st->cr();
13111312

0 commit comments

Comments
 (0)