提交 92cfe745 编写于 作者: D Denghui Dong 提交者: D-D-H

[JFR] Fixed missing Threads_lock protection when traversing thread list

Summary:
TRACE_REQUEST_FUNC(ThreadAllocationStatistics) in jfrPeriodic.cpp
void JfrCheckpointThreadClosure::do_thread(Thread* t) in jfrType.cpp

Test Plan: jdk/test/jdk/jfr

Reviewed-by: kelthuzadx, zhengxiaolinX

Issue: https://github.com/alibaba/dragonwell8/issues/134
上级 e0907c9d
...@@ -395,12 +395,17 @@ TRACE_REQUEST_FUNC(ThreadAllocationStatistics) { ...@@ -395,12 +395,17 @@ TRACE_REQUEST_FUNC(ThreadAllocationStatistics) {
GrowableArray<jlong> allocated(initial_size); GrowableArray<jlong> allocated(initial_size);
GrowableArray<traceid> thread_ids(initial_size); GrowableArray<traceid> thread_ids(initial_size);
JfrTicks time_stamp = JfrTicks::now(); JfrTicks time_stamp = JfrTicks::now();
JfrJavaThreadIterator iter;
while (iter.has_next()) { {
JavaThread* const jt = iter.next(); // Collect allocation statistics while holding threads lock
assert(jt != NULL, "invariant"); MutexLockerEx ml(Threads_lock);
allocated.append(jt->cooked_allocated_bytes()); JfrJavaThreadIterator iter;
thread_ids.append(JFR_THREAD_ID(jt)); while (iter.has_next()) {
JavaThread* const jt = iter.next();
assert(jt != NULL, "invariant");
allocated.append(jt->cooked_allocated_bytes());
thread_ids.append(JFR_THREAD_ID(jt));
}
} }
// Write allocation statistics to buffer. // Write allocation statistics to buffer.
......
...@@ -108,6 +108,7 @@ void JfrCheckpointThreadClosure::do_thread(Thread* t) { ...@@ -108,6 +108,7 @@ void JfrCheckpointThreadClosure::do_thread(Thread* t) {
void JfrThreadConstantSet::serialize(JfrCheckpointWriter& writer) { void JfrThreadConstantSet::serialize(JfrCheckpointWriter& writer) {
JfrCheckpointThreadClosure tc(writer); JfrCheckpointThreadClosure tc(writer);
MutexLockerEx ml(Threads_lock);
JfrJavaThreadIterator javathreads; JfrJavaThreadIterator javathreads;
while (javathreads.has_next()) { while (javathreads.has_next()) {
tc.do_thread(javathreads.next()); tc.do_thread(javathreads.next());
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册