mirror of
https://github.com/openjdk/jdk.git
synced 2026-05-25 21:07:57 +00:00
8244289: fatal error: Possible safepoint reached by thread that does not allow it
Reviewed-by: egahlin
This commit is contained in:
parent
8c9d091f19
commit
61932f49a5
@ -103,7 +103,7 @@ void JfrPostBox::deposit(int new_messages) {
|
||||
void JfrPostBox::asynchronous_post(int msg) {
|
||||
assert(!is_synchronous(msg), "invariant");
|
||||
deposit(msg);
|
||||
JfrMonitorTryLock try_msg_lock(JfrMsg_lock);
|
||||
JfrMutexTryLock try_msg_lock(JfrMsg_lock);
|
||||
if (try_msg_lock.acquired()) {
|
||||
JfrMsg_lock->notify_all();
|
||||
}
|
||||
|
||||
@ -38,6 +38,7 @@
|
||||
#include "jfr/utilities/jfrIterator.hpp"
|
||||
#include "jfr/utilities/jfrLinkedList.inline.hpp"
|
||||
#include "jfr/utilities/jfrTime.hpp"
|
||||
#include "jfr/utilities/jfrTryLock.hpp"
|
||||
#include "jfr/writers/jfrNativeEventWriter.hpp"
|
||||
#include "logging/log.hpp"
|
||||
#include "runtime/javaThread.hpp"
|
||||
@ -316,7 +317,8 @@ static void log_discard(size_t pre_full_count, size_t post_full_count, size_t am
|
||||
}
|
||||
|
||||
void JfrStorage::discard_oldest(Thread* thread) {
|
||||
if (JfrBuffer_lock->try_lock()) {
|
||||
JfrMutexTryLock mutex(JfrBuffer_lock);
|
||||
if (mutex.acquired()) {
|
||||
if (!control().should_discard()) {
|
||||
// another thread handled it
|
||||
return;
|
||||
@ -338,7 +340,6 @@ void JfrStorage::discard_oldest(Thread* thread) {
|
||||
oldest->release(); // publish
|
||||
break;
|
||||
}
|
||||
JfrBuffer_lock->unlock();
|
||||
log_discard(num_full_pre_discard, control().full_count(), discarded_size);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2014, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -50,25 +50,23 @@ class JfrTryLock {
|
||||
}
|
||||
};
|
||||
|
||||
class JfrMonitorTryLock : public StackObj {
|
||||
class JfrMutexTryLock : public StackObj {
|
||||
private:
|
||||
Monitor* _lock;
|
||||
Mutex* _mutex;
|
||||
bool _acquired;
|
||||
|
||||
public:
|
||||
JfrMonitorTryLock(Monitor* lock) : _lock(lock), _acquired(lock->try_lock()) {}
|
||||
|
||||
~JfrMonitorTryLock() {
|
||||
JfrMutexTryLock(Mutex* mutex) : _mutex(mutex), _acquired(mutex->try_lock()) {}
|
||||
~JfrMutexTryLock() {
|
||||
if (_acquired) {
|
||||
assert(_lock->owned_by_self(), "invariant");
|
||||
_lock->unlock();
|
||||
assert(_mutex->owned_by_self(), "invariant");
|
||||
_mutex->unlock();
|
||||
}
|
||||
}
|
||||
|
||||
bool acquired() const {
|
||||
return _acquired;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#endif // SHARE_JFR_UTILITIES_JFRTRYLOCK_HPP
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user