Skip to content
Permalink
Browse files
8254877: GCLogPrecious::_lock rank constrains what locks you are allo…
…wed to have when crashing

Reviewed-by: eosterlund
  • Loading branch information
stefank committed Dec 2, 2020
1 parent 1fd0ea7 commit 287b829c0463018fb05e51d947d7a6783c03f199
Showing with 19 additions and 7 deletions.
  1. +19 −7 src/hotspot/share/gc/shared/gcLogPrecious.cpp
@@ -33,7 +33,7 @@ Mutex* GCLogPrecious::_lock = NULL;
void GCLogPrecious::initialize() {
_lines = new (ResourceObj::C_HEAP, mtGC) stringStream();
_temp = new (ResourceObj::C_HEAP, mtGC) stringStream();
_lock = new Mutex(Mutex::tty,
_lock = new Mutex(Mutex::event, /* The lowest lock rank I could find */
"GCLogPrecious Lock",
true,
Mutex::_safepoint_check_never);
@@ -77,11 +77,23 @@ void GCLogPrecious::vwrite_and_debug(LogTargetHandle log,
}

void GCLogPrecious::print_on_error(outputStream* st) {
if (_lines != NULL) {
MutexLocker locker(_lock, Mutex::_no_safepoint_check_flag);
if (_lines->size() > 0) {
st->print_cr("GC Precious Log:");
st->print_cr("%s", _lines->base());
}
st->print_cr("GC Precious Log:");

if (_lines == NULL) {
st->print_cr("<Not initialized>\n");
return;
}

if (!_lock->try_lock_without_rank_check()) {
st->print_cr("<Skipped>\n");
return;
}

if (_lines->size() == 0) {
st->print_cr("<Empty>\n");
} else {
st->print_cr("%s", _lines->base());
}

_lock->unlock();
}

1 comment on commit 287b829

@openjdk-notifier

This comment has been minimized.

Copy link

@openjdk-notifier openjdk-notifier bot commented on 287b829 Dec 2, 2020

Please sign in to comment.