Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_hotspot
提交
9ff07a77
D
dragonwell8_hotspot
项目概览
openanolis
/
dragonwell8_hotspot
通知
2
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dragonwell8_hotspot
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
9ff07a77
编写于
9月 19, 2012
作者:
K
kevinw
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
7196045: Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
Reviewed-by: sspitsyn, dholmes
上级
59e241c6
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
111 addition
and
11 deletion
+111
-11
src/share/vm/services/management.cpp
src/share/vm/services/management.cpp
+33
-11
test/runtime/7196045/Test7196045.java
test/runtime/7196045/Test7196045.java
+78
-0
未找到文件。
src/share/vm/services/management.cpp
浏览文件 @
9ff07a77
...
...
@@ -1804,31 +1804,37 @@ JVM_END
class
ThreadTimesClosure
:
public
ThreadClosure
{
private:
objArrayOop
_names
;
objArrayHandle
_names_strings
;
char
**
_names_chars
;
typeArrayOop
_times
;
int
_names_len
;
int
_times_len
;
int
_count
;
public:
ThreadTimesClosure
(
objArrayOop
names
,
typeArrayOop
times
);
ThreadTimesClosure
(
objArrayHandle
names
,
typeArrayOop
times
);
~
ThreadTimesClosure
();
virtual
void
do_thread
(
Thread
*
thread
);
void
do_unlocked
();
int
count
()
{
return
_count
;
}
};
ThreadTimesClosure
::
ThreadTimesClosure
(
objArray
Oop
names
,
ThreadTimesClosure
::
ThreadTimesClosure
(
objArray
Handle
names
,
typeArrayOop
times
)
{
assert
(
names
!=
NULL
,
"names was NULL"
);
assert
(
names
()
!=
NULL
,
"names was NULL"
);
assert
(
times
!=
NULL
,
"times was NULL"
);
_names
=
names
;
_names
_strings
=
names
;
_names_len
=
names
->
length
();
_names_chars
=
NEW_C_HEAP_ARRAY
(
char
*
,
_names_len
,
mtInternal
);
_times
=
times
;
_times_len
=
times
->
length
();
_count
=
0
;
}
//
// Called with Threads_lock held
//
void
ThreadTimesClosure
::
do_thread
(
Thread
*
thread
)
{
Handle
s
;
assert
(
thread
!=
NULL
,
"thread was NULL"
);
// exclude externally visible JavaThreads
...
...
@@ -1842,16 +1848,32 @@ void ThreadTimesClosure::do_thread(Thread* thread) {
}
EXCEPTION_MARK
;
ResourceMark
rm
(
THREAD
);
// thread->name() uses ResourceArea
assert
(
thread
->
name
()
!=
NULL
,
"All threads should have a name"
);
s
=
java_lang_String
::
create_from_str
(
thread
->
name
(),
CHECK
);
_names
->
obj_at_put
(
_count
,
s
());
_names_chars
[
_count
]
=
strdup
(
thread
->
name
());
_times
->
long_at_put
(
_count
,
os
::
is_thread_cpu_time_supported
()
?
os
::
thread_cpu_time
(
thread
)
:
-
1
);
_count
++
;
}
// Called without Threads_lock, we can allocate String objects.
void
ThreadTimesClosure
::
do_unlocked
()
{
EXCEPTION_MARK
;
for
(
int
i
=
0
;
i
<
_count
;
i
++
)
{
Handle
s
=
java_lang_String
::
create_from_str
(
_names_chars
[
i
],
CHECK
);
_names_strings
->
obj_at_put
(
i
,
s
());
}
}
ThreadTimesClosure
::~
ThreadTimesClosure
()
{
for
(
int
i
=
0
;
i
<
_count
;
i
++
)
{
free
(
_names_chars
[
i
]);
}
FREE_C_HEAP_ARRAY
(
char
*
,
_names_chars
,
mtInternal
);
}
// Fills names with VM internal thread names and times with the corresponding
// CPU times. If names or times is NULL, a NullPointerException is thrown.
// If the element type of names is not String, an IllegalArgumentException is
...
...
@@ -1878,12 +1900,12 @@ JVM_ENTRY(jint, jmm_GetInternalThreadTimes(JNIEnv *env,
typeArrayOop
ta
=
typeArrayOop
(
JNIHandles
::
resolve_non_null
(
times
));
typeArrayHandle
times_ah
(
THREAD
,
ta
);
ThreadTimesClosure
ttc
(
names_ah
()
,
times_ah
());
ThreadTimesClosure
ttc
(
names_ah
,
times_ah
());
{
MutexLockerEx
ml
(
Threads_lock
);
Threads
::
threads_do
(
&
ttc
);
}
ttc
.
do_unlocked
();
return
ttc
.
count
();
JVM_END
...
...
test/runtime/7196045/Test7196045.java
0 → 100644
浏览文件 @
9ff07a77
/*
* Copyright (c) 2012, 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
/*
* @test
* @bug 7196045
* @summary Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
* @run main/othervm
*/
import
java.lang.management.ManagementFactory
;
import
javax.management.JMException
;
import
javax.management.MBeanServer
;
import
javax.management.MalformedObjectNameException
;
import
javax.management.ObjectName
;
public
class
Test7196045
{
public
static
long
duration
=
1000
*
60
*
2
;
private
static
final
String
HOTSPOT_INTERNAL
=
"sun.management:type=HotspotInternal"
;
public
static
void
main
(
String
[]
args
)
{
MBeanServer
server
=
ManagementFactory
.
getPlatformMBeanServer
();
ObjectName
objName
=
null
;
try
{
ObjectName
hotspotInternal
=
new
ObjectName
(
HOTSPOT_INTERNAL
);
try
{
server
.
registerMBean
(
new
sun
.
management
.
HotspotInternal
(),
hotspotInternal
);
}
catch
(
JMException
e
)
{
throw
new
RuntimeException
(
"HotSpotWatcher: Failed to register the HotspotInternal MBean"
+
e
);
}
objName
=
new
ObjectName
(
"sun.management:type=HotspotThreading"
);
}
catch
(
MalformedObjectNameException
e1
)
{
throw
new
RuntimeException
(
"Bad object name"
+
e1
);
}
long
endTime
=
System
.
currentTimeMillis
()
+
duration
;
long
i
=
0
;
while
(
true
)
{
try
{
server
.
getAttribute
(
objName
,
"InternalThreadCpuTimes"
);
}
catch
(
Exception
ex
)
{
System
.
err
.
println
(
"Exception while getting attribute: "
+
ex
);
}
i
++;
if
(
i
%
10000
==
0
)
{
System
.
out
.
println
(
"Successful iterations: "
+
i
);
}
if
(
System
.
currentTimeMillis
()
>
endTime
)
{
break
;
}
}
System
.
out
.
println
(
"PASSED."
);
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录