Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perfcounter 执行出错时提示信息不完整 #2364

Closed
1 task done
GGGGGHT opened this issue Dec 4, 2022 · 1 comment
Closed
1 task done

perfcounter 执行出错时提示信息不完整 #2364

GGGGGHT opened this issue Dec 4, 2022 · 1 comment

Comments

@GGGGGHT
Copy link
Contributor

GGGGGHT commented Dec 4, 2022

  • 我已经在 issues 里搜索,没有重复的issue。

环境信息

  • Arthas 版本: 3.6.6
  • 操作系统版本: 5.15.0-56-generic 20.04.1-Ubuntu
  • 目标进程的JVM版本: java version "17.0.4" 2022-07-19 LTS

重现问题的步骤

  1. attach到目标进程后执行perfcounter

期望的结果

正确输出相关结果

实际运行的结果

please check arthas log. if java version >=9 , try to add jvm options when start your process: --add-opens java.base/jdk.internal.perf=ALL-UNNAMED --add-exports java.base/jdk.internal.perf=ALL-UNNAMED

java.lang.IllegalAccessError: class com.taobao.arthas.core.command.monitor200.PerfCounterCommand (in unnamed module @0x22b84315) cannot access class sun.management.counter.perf.PerfInstrumentation (in module java.management) because module java.management does not export sun.management.counter.perf to unnamed module @0x22b84315
	at com.taobao.arthas.core.command.monitor200.PerfCounterCommand.getPerfCounters(PerfCounterCommand.java:105)
	at com.taobao.arthas.core.command.monitor200.PerfCounterCommand.process(PerfCounterCommand.java:53)
	at com.taobao.arthas.core.shell.command.impl.AnnotatedCommandImpl.process(AnnotatedCommandImpl.java:82)
	at com.taobao.arthas.core.shell.command.impl.AnnotatedCommandImpl.access$100(AnnotatedCommandImpl.java:18)
	at com.taobao.arthas.core.shell.command.impl.AnnotatedCommandImpl$ProcessHandler.handle(AnnotatedCommandImpl.java:111)
	at com.taobao.arthas.core.shell.command.impl.AnnotatedCommandImpl$ProcessHandler.handle(AnnotatedCommandImpl.java:108)
	at com.taobao.arthas.core.shell.system.impl.ProcessImpl$CommandProcessTask.run(ProcessImpl.java:385)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
	at java.base/java.lang.Thread.run(Thread.java:833)

FIX

根据异常信息查看 未导出 sun.management.counter.perf.PerfInstrumentation 使用 java --describe-module java.management 得出以下信息

java.management@17.0.4
exports java.lang.management
exports javax.management
exports javax.management.loading
exports javax.management.modelmbean
exports javax.management.monitor
exports javax.management.openmbean
exports javax.management.relation
exports javax.management.remote
exports javax.management.timer
requires java.base mandated
uses sun.management.spi.PlatformMBeanProvider
uses javax.management.remote.JMXConnectorServerProvider
uses javax.management.remote.JMXConnectorProvider
provides javax.security.auth.spi.LoginModule with com.sun.jmx.remote.security.FileLoginModule
qualified exports sun.management.counter to jdk.management.agent
qualified exports sun.management.spi to jdk.management.jfr jdk.management
qualified exports sun.management to jdk.management jdk.management.agent jdk.jconsole
qualified exports sun.management.counter.perf to jdk.management.agent
qualified exports com.sun.jmx.remote.internal to jdk.management.agent java.management.rmi
qualified exports com.sun.jmx.remote.security to jdk.management.agent java.management.rmi
qualified exports com.sun.jmx.remote.util to java.management.rmi
contains com.sun.jmx.defaults
contains com.sun.jmx.interceptor
contains com.sun.jmx.mbeanserver

所以需要在目标进程启动之前加上--add-opens java.management/sun.management.counter.perf=ALL-UNNAMED --add-opens java.management/sun.management.counter=ALL-UNNAMED 启动参数 但是在执行完perfcounter之后并未提示相关信息.

@hengyunabc
Copy link
Collaborator

欢迎提交PR😀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants