提交 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,6 +395,10 @@ TRACE_REQUEST_FUNC(ThreadAllocationStatistics) {
GrowableArray<jlong> allocated(initial_size);
GrowableArray<traceid> thread_ids(initial_size);
JfrTicks time_stamp = JfrTicks::now();
{
// Collect allocation statistics while holding threads lock
MutexLockerEx ml(Threads_lock);
JfrJavaThreadIterator iter;
while (iter.has_next()) {
JavaThread* const jt = iter.next();
......@@ -402,6 +406,7 @@ TRACE_REQUEST_FUNC(ThreadAllocationStatistics) {
allocated.append(jt->cooked_allocated_bytes());
thread_ids.append(JFR_THREAD_ID(jt));
}
}
// Write allocation statistics to buffer.
for(int i = 0; i < thread_ids.length(); i++) {
......
......@@ -108,6 +108,7 @@ void JfrCheckpointThreadClosure::do_thread(Thread* t) {
void JfrThreadConstantSet::serialize(JfrCheckpointWriter& writer) {
JfrCheckpointThreadClosure tc(writer);
MutexLockerEx ml(Threads_lock);
JfrJavaThreadIterator javathreads;
while (javathreads.has_next()) {
tc.do_thread(javathreads.next());
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册