From 2ea62c136925299d4b767a0149419e7e9de3629a Mon Sep 17 00:00:00 2001 From: Coleen Phillimore Date: Mon, 24 Apr 2023 21:23:56 +0000 Subject: [PATCH] 8303276: Secondary assertion failure in AdapterHandlerLibrary::contains during crash reporting Reviewed-by: iklam, stuefe --- src/hotspot/share/classfile/classLoaderDataGraph.cpp | 3 +-- src/hotspot/share/runtime/mutexLocker.cpp | 8 ++++---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/hotspot/share/classfile/classLoaderDataGraph.cpp b/src/hotspot/share/classfile/classLoaderDataGraph.cpp index 7a1c499b9e3..c4241749fcf 100644 --- a/src/hotspot/share/classfile/classLoaderDataGraph.cpp +++ b/src/hotspot/share/classfile/classLoaderDataGraph.cpp @@ -45,7 +45,6 @@ #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; @@ -476,7 +475,7 @@ bool ClassLoaderDataGraph::contains_loader_data(ClassLoaderData* loader_data) { #endif // PRODUCT bool ClassLoaderDataGraph::is_valid(ClassLoaderData* loader_data) { - DEBUG_ONLY( if (!VMError::is_error_reported()) { assert_locked_or_safepoint(ClassLoaderDataGraph_lock); } ) + assert_locked_or_safepoint(ClassLoaderDataGraph_lock); if (loader_data != nullptr) { if (loader_data == ClassLoaderData::the_null_class_loader_data()) { return true; diff --git a/src/hotspot/share/runtime/mutexLocker.cpp b/src/hotspot/share/runtime/mutexLocker.cpp index 5be72c4e663..a46f0ba0063 100644 --- a/src/hotspot/share/runtime/mutexLocker.cpp +++ b/src/hotspot/share/runtime/mutexLocker.cpp @@ -30,9 +30,9 @@ #include "memory/universe.hpp" #include "runtime/javaThread.hpp" #include "runtime/mutexLocker.hpp" -#include "runtime/os.inline.hpp" #include "runtime/safepoint.hpp" #include "runtime/vmThread.hpp" +#include "utilities/vmError.hpp" // Mutexes used in the VM (see comment in mutexLocker.hpp): @@ -166,7 +166,7 @@ static int _num_mutex; #ifdef ASSERT void assert_locked_or_safepoint(const Mutex* lock) { - if (DebuggingContext::is_enabled()) return; + if (DebuggingContext::is_enabled() || VMError::is_error_reported()) return; // check if this thread owns the lock (common case) assert(lock != nullptr, "Need non-null lock"); if (lock->owned_by_self()) return; @@ -177,7 +177,7 @@ void assert_locked_or_safepoint(const Mutex* lock) { // a weaker assertion than the above void assert_locked_or_safepoint_weak(const Mutex* lock) { - if (DebuggingContext::is_enabled()) return; + if (DebuggingContext::is_enabled() || VMError::is_error_reported()) return; assert(lock != nullptr, "Need non-null lock"); if (lock->is_locked()) return; if (SafepointSynchronize::is_at_safepoint()) return; @@ -187,7 +187,7 @@ void assert_locked_or_safepoint_weak(const Mutex* lock) { // a stronger assertion than the above void assert_lock_strong(const Mutex* lock) { - if (DebuggingContext::is_enabled()) return; + if (DebuggingContext::is_enabled() || VMError::is_error_reported()) return; assert(lock != nullptr, "Need non-null lock"); if (lock->owned_by_self()) return; fatal("must own lock %s", lock->name());