提交 61c15a46 编写于 作者: K kamg

6814943: getcpool001 catches more than one JvmtiThreadState problem

Summary: Mark field volatile, use membars, and change access order to close race
Reviewed-by: dcubed, dholmes
上级 8b06765f
...@@ -667,14 +667,13 @@ void ...@@ -667,14 +667,13 @@ void
JvmtiEventControllerPrivate::thread_ended(JavaThread *thread) { JvmtiEventControllerPrivate::thread_ended(JavaThread *thread) {
// Removes the JvmtiThreadState associated with the specified thread. // Removes the JvmtiThreadState associated with the specified thread.
// May be called after all environments have been disposed. // May be called after all environments have been disposed.
assert(JvmtiThreadState_lock->is_locked(), "sanity check");
EC_TRACE(("JVMTI [%s] # thread ended", JvmtiTrace::safe_get_thread_name(thread))); EC_TRACE(("JVMTI [%s] # thread ended", JvmtiTrace::safe_get_thread_name(thread)));
JvmtiThreadState *state = thread->jvmti_thread_state(); JvmtiThreadState *state = thread->jvmti_thread_state();
if (state != NULL) { assert(state != NULL, "else why are we here?");
MutexLocker mu(JvmtiThreadState_lock); delete state;
delete state;
}
} }
void JvmtiEventControllerPrivate::set_event_callbacks(JvmtiEnvBase *env, void JvmtiEventControllerPrivate::set_event_callbacks(JvmtiEnvBase *env,
......
...@@ -2253,12 +2253,14 @@ void JvmtiExport::post_vm_object_alloc(JavaThread *thread, oop object) { ...@@ -2253,12 +2253,14 @@ void JvmtiExport::post_vm_object_alloc(JavaThread *thread, oop object) {
void JvmtiExport::cleanup_thread(JavaThread* thread) { void JvmtiExport::cleanup_thread(JavaThread* thread) {
assert(JavaThread::current() == thread, "thread is not current"); assert(JavaThread::current() == thread, "thread is not current");
MutexLocker mu(JvmtiThreadState_lock);
if (thread->jvmti_thread_state() != NULL) {
// This has to happen after the thread state is removed, which is // This has to happen after the thread state is removed, which is
// why it is not in post_thread_end_event like its complement // why it is not in post_thread_end_event like its complement
// Maybe both these functions should be rolled into the posts? // Maybe both these functions should be rolled into the posts?
JvmtiEventController::thread_ended(thread); JvmtiEventController::thread_ended(thread);
}
} }
void JvmtiExport::oops_do(OopClosure* f) { void JvmtiExport::oops_do(OopClosure* f) {
......
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
#include "compiler/compileBroker.hpp" #include "compiler/compileBroker.hpp"
#include "interpreter/interpreter.hpp" #include "interpreter/interpreter.hpp"
#include "interpreter/linkResolver.hpp" #include "interpreter/linkResolver.hpp"
#include "jvmtifiles/jvmtiEnv.hpp"
#include "memory/oopFactory.hpp" #include "memory/oopFactory.hpp"
#include "memory/universe.inline.hpp" #include "memory/universe.inline.hpp"
#include "oops/instanceKlass.hpp" #include "oops/instanceKlass.hpp"
...@@ -1699,7 +1700,7 @@ void JavaThread::exit(bool destroy_vm, ExitType exit_type) { ...@@ -1699,7 +1700,7 @@ void JavaThread::exit(bool destroy_vm, ExitType exit_type) {
tlab().make_parsable(true); // retire TLAB tlab().make_parsable(true); // retire TLAB
} }
if (jvmti_thread_state() != NULL) { if (JvmtiEnv::environments_might_exist()) {
JvmtiExport::cleanup_thread(this); JvmtiExport::cleanup_thread(this);
} }
......
...@@ -809,7 +809,7 @@ class JavaThread: public Thread { ...@@ -809,7 +809,7 @@ class JavaThread: public Thread {
// //
// _vm_exited is a special value to cover the case of a JavaThread // _vm_exited is a special value to cover the case of a JavaThread
// executing native code after the VM itself is terminated. // executing native code after the VM itself is terminated.
TerminatedTypes _terminated; volatile TerminatedTypes _terminated;
// suspend/resume support // suspend/resume support
volatile bool _suspend_equivalent; // Suspend equivalent condition volatile bool _suspend_equivalent; // Suspend equivalent condition
jint _in_deopt_handler; // count of deoptimization jint _in_deopt_handler; // count of deoptimization
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册