JBR-5722 vmTestbase/vm/gc/compact/Compact_TwoFields_InternedStrings: SIGSEGV at Symbol::as_klass_external_name(char*, int)

Do not use print_native_stack() when recording OOME stacks as it is
designed to be used only in the context of a fatal error reporting where
induced crashes are tolerated.
This commit is contained in:
Maxim Kartashev
2023-06-20 18:20:00 +04:00
committed by jbrbot
parent 6266825658
commit aaa1893c22
2 changed files with 18 additions and 19 deletions

View File

@@ -47,6 +47,7 @@
#include "utilities/growableArray.hpp"
#include "utilities/macros.hpp"
#include "utilities/ostream.hpp"
#include "utilities/vmError.hpp"
volatile size_t ClassLoaderDataGraph::_num_array_classes = 0;
volatile size_t ClassLoaderDataGraph::_num_instance_classes = 0;
@@ -186,7 +187,8 @@ ClassLoaderData* ClassLoaderDataGraph::add(Handle loader, bool has_class_mirror_
inline void assert_is_safepoint_or_gc() {
assert(SafepointSynchronize::is_at_safepoint() ||
Thread::current()->is_ConcurrentGC_thread() ||
Thread::current()->is_Worker_thread(),
Thread::current()->is_Worker_thread() ||
VMError::is_error_reported(), // don't crash here again if we have already crashed
"Must be called by safepoint or GC");
}

View File

@@ -2197,28 +2197,25 @@ void VMError::init() {
}
void VMError::record_oome_stack(const char *message) {
MutexLocker ml(OOMEStacks_lock);
static char buf[O_BUFLEN];
address lastpc = nullptr;
stringStream st(_oome_stacktrace[_oome_free_index], OOME_STACKTRACE_BUFSIZE);
st.print_cr("OutOfMemoryError(\"%s\"):", message);
if (os::platform_print_native_stack(&st, _context, buf, sizeof(buf), lastpc)) {
// We have printed the native stack in platform-specific code
// Windows/x64 needs special handling.
} else {
print_native_stack(&st, os::current_frame(), Thread::current(), true, -1, buf, sizeof(buf));
_print_native_stack_used = true;
Thread * thread = Thread::current();
if (!thread->is_Java_thread()) {
// The following code can't work in non-Java thread.
// Besides, it's not a true OOM *exception* if there's no Java on the stack.
return;
}
st.cr();
{
MutexLocker ml(OOMEStacks_lock);
ResourceMark rm;
if (Thread::current()->is_Java_thread()) {
print_stack_trace(&st, JavaThread::current(), buf, sizeof(buf));
stringStream st(_oome_stacktrace[_oome_free_index], OOME_STACKTRACE_BUFSIZE);
st.print_cr("OutOfMemoryError(\"%s\") on the thread \"%s\"", message, thread->name());
JavaThread::cast(thread)->print_stack_on(&st);
st.cr();
_oome_free_index = (_oome_free_index + 1) % OOME_STACKTRACE_COUNT;
}
_oome_free_index = (_oome_free_index + 1) % OOME_STACKTRACE_COUNT;
}
void VMError::print_oome_stacks(outputStream *st) {