profile
viewpoint
hengyunabc hengyunabc Alibaba http://hengyunabc.github.io/ 横云断岭, Spring Boot, APM, Arthas, Dubbo 微信公众号:横云断岭的专栏

alibaba/arthas 23139

Alibaba Java Diagnostic Tool Arthas/Alibaba Java诊断利器Arthas

hengyunabc/dubbo-arthas-demo 82

演示Arthas排查Dubbo问题的Demo

hengyunabc/dubbo-apache-commons-collections-bug 38

演示dubbo rpc Apache commons collections 的Java序列化漏洞

issue closedalibaba/arthas

watch命令,可以打印线程吗?

如果可以的话,感觉帮助会大一些

closed time in 16 hours

ruiruige

issue commentalibaba/arthas

Kubernetes(k8s)且应用集群部署环境下agent-id该如何配置

arthas starter里的代码其实很简单的,可以自己封装下,自己决定怎么生成 agentId 。

或者利用 k8s /docker本身的功能,设置一些环境变量,然后注入到spring env里来做为 agent id。

或者自己开发下 tunnel server,反查出应用和 agent之间的关系。

uzdz

comment created time in 16 hours

push eventalibaba/arthas

hengyunabc

commit sha 7d17fd3bafecfbf81fdf06fcd3c0537fc160d628

update doc

view details

push time in 17 hours

push eventalibaba/arthas

hengyunabc

commit sha bdd801739910fce426b98c12e02dbbb7a048f93b

update spring-boot-starter.md

view details

push time in 17 hours

issue closedalibaba/arthas

在执行命令的时候,有的时候我想通过点击方向键上,或者下来切换历史指令不生效,甚至点击方向键左右移动也不生效,不是特别方便

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

环境信息

  • arthas-boot.jar 或者 as.sh 的版本: 3.3.7
  • Arthas 版本: xxx
  • 操作系统版本: win 10
  • 目标进程的JVM版本: 1.8.0_71-b15
  • 执行arthas-boot的版本: xxx

期望的结果

按上下方向键可以切换历史指令

closed time in a day

XudongFu

issue closedalibaba/arthas

windows环境下方向键快捷键无效

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

环境信息

  • arthas-boot.jar 或者 as.sh 的版本: 3.3.3
  • Arthas 版本: 3.3.3
  • 操作系统版本: windows 10
  • 目标进程的JVM版本: jdk8
  • 执行arthas-boot的版本: 3.3.3

重现问题的步骤

  1. java -jar arthas-boot.jar 2.执行任意命令
  2. 按 上,下,左,右 任意键盘方向键

期望的结果

左右键,为前进后退一个字符 上下键,为上一条,下一条命令

实际运行的结果

完全无效,没任何反应

closed time in a day

oicq1699

issue commentalibaba/arthas

windows环境下方向键快捷键无效

试下最新的 3.4.3 版本,应该支持 cmd里各种快捷键了。

oicq1699

comment created time in a day

issue closedalibaba/arthas

执行trace命令抛异常,Enhancer error,java.lang.ClassFormatError: null

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

环境信息

  • arthas-boot.jar 或者 as.sh 的版本: xxx
  • Arthas 版本: xxx
  • 操作系统版本: Red Hat Enterprise Linux Server release 6.6 (Santiago)
  • 目标进程的JVM版本: java version "1.8.0_172-ea"
  • 执行arthas-boot的版本: arthas-boot version: 3.3.3

重现问题的步骤

  1. trace com.sf.nwms.inventory.inv.service.impl.InvQueryServiceImpl queryLocationInvList
  2. xxx
  3. xxx

期望的结果

What do you expected from the above steps?

实际运行的结果

实际运行结果,最好有详细的日志,异常栈。尽量贴文本。

把异常信息贴到这里
2020-09-17 10:11:45 [arthas-binding-thread] INFO  c.t.a.core.server.ArthasBootstrap -as-server started in 713 ms
Arthas server already bind.
2020-09-17 10:11:45 [nioEventLoopGroup-2-1] INFO  i.n.handler.logging.LoggingHandler -[id: 0xc391befe, L:/127.0.0.1:3658] READ: [id: 0x4a940d78, L:/127.0.0.1:3658 - R:/127.0.0.1:48184]
2020-09-17 10:11:45 [nioEventLoopGroup-2-1] INFO  i.n.handler.logging.LoggingHandler -[id: 0xc391befe, L:/127.0.0.1:3658] READ COMPLETE
2020-09-17 10:11:46 [nioEventLoopGroup-2-2] INFO  c.t.a.core.shell.term.impl.Helper -Loaded arthas keymap file from com/taobao/arthas/core/shell/term/readline/inputrc
2020-09-17 10:12:18 [as-command-execute-daemon] INFO  c.t.arthas.core.advisor.Enhancer -enhance matched classes: [class com.sf.nwms.inventory.inv.service.impl.InvQueryServiceImpl$$EnhancerBySpringCGLIB$$ce393cee, class com.sf.nwms.inventory.inv.service.impl.InvQueryServiceImpl]
2020-09-17 10:12:18 [as-command-execute-daemon] ERROR c.t.arthas.core.advisor.Enhancer -Enhancer error, matchingClasses: [class com.sf.nwms.inventory.inv.service.impl.InvQueryServiceImpl$$EnhancerBySpringCGLIB$$ce393cee, class com.sf.nwms.inventory.inv.service.impl.InvQueryServiceImpl]
java.lang.ClassFormatError: null
        at sun.instrument.InstrumentationImpl.retransformClasses0(Native Method)
        at sun.instrument.InstrumentationImpl.retransformClasses(InstrumentationImpl.java:144)
        at com.taobao.arthas.core.advisor.Enhancer.enhance(Enhancer.java:366)
        at com.taobao.arthas.core.command.monitor200.EnhancerCommand.enhance(EnhancerCommand.java:135)
        at com.taobao.arthas.core.command.monitor200.EnhancerCommand.process(EnhancerCommand.java:87)
        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:372)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:748)
2020-09-17 10:35:30 [nioEventLoopGroup-2-2] INFO  c.t.a.c.shell.impl.ShellServerImpl -Session fe4e4490-de78-42f7-8080-69aad0e522a3 closed, so terminate foreground job, id: 1, line: trace com.sf.nwms.inventory.inv

closed time in a day

hhzhong

issue commentalibaba/arthas

执行trace命令抛异常,Enhancer error,java.lang.ClassFormatError: null

试下最新的 3.4.3 版本,应该已经修复了。

hhzhong

comment created time in a day

push eventalibaba/arthas

hengyunabc

commit sha b9aabe42007d2dbc64ebf352901c417b15723535

[maven-release-plugin] prepare for next development iteration

view details

push time in a day

created tagalibaba/arthas

tagarthas-all-3.4.3

Alibaba Java Diagnostic Tool Arthas/Alibaba Java诊断利器Arthas

created time in a day

push eventalibaba/arthas

hengyunabc

commit sha 4268b4d13e7a81ed4803cd9d7a23e340e14adbdd

[maven-release-plugin] prepare release arthas-all-3.4.3

view details

push time in a day

push eventalibaba/arthas

hengyunabc

commit sha a6b68321ae977bd73545a58f45dff4d30e04beaf

prepare release 3.4.3

view details

push time in a day

issue closedalibaba/arthas

当jdk 14启用 --enable-preview 时,复杂的类 watch/trace出错

java.lang.UnsupportedOperationException: class redefinition failed: attempted to change the class NestHost, NestMembers, or Record attribute
        at java.instrument/sun.instrument.InstrumentationImpl.retransformClasses0(Native Method)
        at java.instrument/sun.instrument.InstrumentationImpl.retransformClasses(InstrumentationImpl.java:167)
        at com.taobao.arthas.core.advisor.Enhancer.enhance(Enhancer.java:371)
        at com.taobao.arthas.core.command.monitor200.EnhancerCommand.enhance(EnhancerCommand.java:149)
        at com.taobao.arthas.core.command.monitor200.EnhancerCommand.process(EnhancerCommand.java:96)
        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:515)
        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:1130)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630)
        at java.base/java.lang.Thread.run(Thread.java:832)

asm已升级为最新版本 9.0,并且使用了最新的API ASM9 。


复现demo:

public class BBB {
    public String test() {
        return "hello";
    }
}
public class FFF {
    public String test() {
        
        Thread t = new Thread(new Runnable() {

            @Override
            public void run() {
                System.err.println("ttt");
            }
            
        });
        t.start();
        return "hello";
    }
}
import java.io.IOException;

public class TTT {
    
    public static void main(String[] args) throws  IOException {
        
        System.err.println(new FFF());
        System.err.println(new BBB());
        System.in.read();
        
    }

}
  • 建立上面三个文件
  • 使用jdk 14来编译:jdk-14.0.2.jdk/Contents/Home/bin/javac --enable-preview --release 14 ./*.java
  • 启动: jdk-14.0.2.jdk/Contents/Home/bin/java --enable-preview TTT
  • 启动 arthas attach
  • watch BBB test ,这个是正常结果
  • watch FFF test ,会抛出上面的异常

closed time in a day

hengyunabc

issue closedalibaba/arthas

Upgrade asm to 9.0

closed time in a day

hengyunabc

issue closedalibaba/arthas

jdk8下 jad 查看包含lambda的类,导致应用抛出 ClassNotFoundException 和 NoClassDefFoundError 问题

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

环境信息

  • arthas-boot.jar 或者 as.sh 的版本: 3.4.1
  • Arthas 版本: 3.4.1
  • 操作系统版本: windows 10 19041.508
  • 目标进程的JVM版本: jdk1.8.0_212
  • 执行arthas-boot的版本: 3.4.1

重现问题的步骤

public class Test {

    public static void main(String[] args) throws InterruptedException {
        Test test = new Test();
        while (true) {
            try {
                AtomicInteger i = new AtomicInteger();
                Runnable runnable = () -> {
                    i.getAndIncrement();
                };
            } catch (NoClassDefFoundError e) {
                e.printStackTrace();
                Thread.sleep(2000);
            }
        }
    }
}

运行上述代码,并用arthas attach,然后使用命令 jad package.Test. 虽然可以正确反编译类的内容,但上述程序开始抛出异常。

java.lang.NoClassDefFoundError: cn/willingxyz/javaagent/Test$$Lambda$1
        at cn.willingxyz.javaagent.Test$$Lambda$1/1156060786.get$Lambda(Unknown Source)
        at cn.willingxyz.javaagent.Test.main(Test.java:18)

可能和 https://bugs.openjdk.java.net/browse/JDK-8145964 这个bug有关,不过jad命令(和其他相关命令)是否能够绕开该bug。

closed time in a day

Willing-Xyz

issue commentalibaba/arthas

jdk8下 jad 查看包含lambda的类,导致应用抛出 ClassNotFoundException 和 NoClassDefFoundError 问题

同样 watch等命令也会有类似问题,已处理。 watch Test* *

Willing-Xyz

comment created time in a day

push eventalibaba/arthas

hengyunabc

commit sha 59dd38308475a1b7ea8aea75eb4d6f8957eb2829

avoid retransform lambda class. #1512

view details

push time in a day

push eventalibaba/arthas

hengyunabc

commit sha 4abcac9b65dd9e36cca89db5f95a5e004a94d505

avoid retransform lambda class. #1512

view details

push time in a day

issue commentalibaba/arthas

jdk8下 jad 查看包含lambda的类,导致应用抛出 ClassNotFoundException 和 NoClassDefFoundError 问题

实际上 jdk11,会retransform lambda类时,没回调 ClassFileTransformer 就抛出异常了。 也就是说 jdk11下面,拿不到 lambda类的字节码。

但是jdk8下可以拿到,但是会导致应用出错。 应用实际是先抛出 ClassNotFoundException ,然后第二次就会变成 NoClassDefFoundError 。

java.lang.NoClassDefFoundError: Test$$Lambda$1
	at Test$$Lambda$1/1418481495.get$Lambda(Unknown Source)
	at Test.main(Test.java:12)
Caused by: java.lang.ClassNotFoundException: Test$$Lambda$1
	at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
	... 2 more
java.lang.NoClassDefFoundError: Test$$Lambda$1
	at Test$$Lambda$1/1418481495.get$Lambda(Unknown Source)
	at Test.main(Test.java:12)

目前而言,最好是直接不 retransform lambda类。

Willing-Xyz

comment created time in a day

issue commentalibaba/arthas

jad 查看包含lambda的类,会导致类所在进程(!!!)抛出NoClassDefFoundError

jdk8 和jdk11的不同之处,应该是 jdk11在 retransform lambda类时,直接抛出了异常。而jdk8还是正常处理,然后导致新的字节码出错。

java.lang.instrument.UnmodifiableClassException: null
        at java.instrument/sun.instrument.InstrumentationImpl.retransformClasses0(Native Method)
        at java.instrument/sun.instrument.InstrumentationImpl.retransformClasses(InstrumentationImpl.java:167)
        at com.taobao.arthas.core.util.InstrumentationUtils.retransformClasses(InstrumentationUtils.java:25)
        at com.taobao.arthas.core.command.klass100.JadCommand.processExactMatch(JadCommand.java:166)
        at com.taobao.arthas.core.command.klass100.JadCommand.process(JadCommand.java:147)
        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:515)
        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:1128)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
        at java.base/java.lang.Thread.run(Thread.java:834)
Willing-Xyz

comment created time in 2 days

issue commentalibaba/arthas

jad 查看包含lambda的类,会导致类所在进程(!!!)抛出NoClassDefFoundError

原始的 Test.class类里,引用的lambda类是 lambda$0

  #66 = Methodref          #1.#67         // Test.lambda$0:(Ljava/util/concurrent/atomic/AtomicInteger;)V
  #67 = NameAndType        #49:#50        // lambda$0:(Ljava/util/concurrent/atomic/AtomicInteger;)V
  #68 = MethodHandle       #6:#66         // invokestatic Test.lambda$0:(Ljava/util/concurrent/atomic/AtomicInteger;)V

调试的栈也是 lambda$0

Thread [Thread-0] (Suspended (breakpoint at line 13 in Test))	
	Test.lambda$0(AtomicInteger) line: 13	
	1620303253.run() line: not available	
	Thread.run() line: 748	


但是抛出异常的栈显示:

java.lang.NoClassDefFoundError: Test$$Lambda$1
	at Test$$Lambda$1/1418481495.get$Lambda(Unknown Source)
	at Test.main(Test.java:12)

可见的确是jdk bug问题。

Willing-Xyz

comment created time in 2 days

PR closed alibaba/arthas

fix arthas-client windows cmd shortcuts support.

jline already wrapper stdin, processing up/down/left/right arrow keys, just use consoleReader.getInput() instead of System.in.

+1 -1

7 comments

1 changed file

kylixs

pr closed time in 2 days

PR closed alibaba/arthas

Fixed for up/down key issue on windows

ref: https://github.com/alibaba/arthas/pull/616

+2 -5

2 comments

1 changed file

qxo

pr closed time in 2 days

pull request commentalibaba/arthas

Fixed for up/down key issue on windows

测试了下,注释掉代码和键盘输入没有关系,是否显示颜色的。

qxo

comment created time in 2 days

push eventalibaba/arthas

hengyunabc

commit sha 4b2d182518c7a35d0f60e554c54e4e3b4bb6c974

fix arthas-client windows cmd shortcuts support. #616

view details

push time in 2 days

pull request commentalibaba/arthas

fix: arthas telnet client no capture up/down arrow key on windows

这个地方改用 consoleReader.getInput() 会有问题,好像是 ctrl + c 会直接退出进程。 在git bash/mingw 下面好像不能工作。

最开始的版本是直接用的 consoleReader.getInput() ,这个也是合理的。但当时为了支持 mingw,用了 System.in

但现在测试发现 mingw下,ctrl + c 还是会直接退出进程。

另外,在windows下,用 cmd的应该才是多数。所以不考虑 mingw之类的支持了。如果有更多的需求,建议直接用 telent本身来连接。

kylixs

comment created time in 2 days

issue closedalibaba/termd

build problem

本地打包之后,运行arthas时跑不起来,但是从官方仓库拉下来就可以正常跑,是我哪里打包的不对吗,也不像是代码的问题

closed time in 2 days

Luyao1271

issue commentalibaba/termd

build problem

去掉加载 terminfo.src 的代码了,应该没这个问题了。

Luyao1271

comment created time in 2 days

issue closedalibaba/termd

load too many term device

Generally we only need a few term devices, but more than 2600 are loaded and 11MB of memory is used. Please optimize the loading of term devices to reduce unnecessary memory.

image image

closed time in 2 days

kylixs

push eventalibaba/arthas

hengyunabc

commit sha f775b0fd42dd30d74bf768c5f992d9663bb7c8f4

Upgrad termd to 1.1.7.10 , remove unnecessary code #1529

view details

push time in 2 days

issue closedalibaba/termd

去掉无用的加载 TermInfo 的代码

在代码里实际上没用到,没必要加载。

closed time in 2 days

hengyunabc

issue commentalibaba/arthas

Upgrad termd to 1.1.7.10 , remove unnecessary code

https://github.com/alibaba/termd/issues/42

https://github.com/alibaba/arthas/issues/1186

hengyunabc

comment created time in 2 days

push eventalibaba/termd

hengyunabc

commit sha 9bdf0b2836c4deb5d5b7a8d3fc0334ab2201ffec

[maven-release-plugin] prepare for next development iteration

view details

push time in 2 days

created tagalibaba/termd

tagtermd-core-1.1.7.10

created time in 2 days

push eventalibaba/termd

hengyunabc

commit sha 3b97f9904580eb4218e21ced23e6916ef14a8886

[maven-release-plugin] prepare release termd-core-1.1.7.10

view details

push time in 2 days

push eventalibaba/termd

hengyunabc

commit sha e5ec9d3a72a2f69f1dba50624e9f3901801e6309

remove unnecessary code about load Device Info. #42

view details

push time in 2 days

issue commentalibaba/termd

去掉无用的加载 TermInfo 的代码

https://github.com/alibaba/arthas/issues/1245

https://github.com/alibaba/arthas/issues/1186

hengyunabc

comment created time in 2 days

issue openedalibaba/termd

去掉无用的加载 TermInfo 的代码

在代码里实际上没用到,没必要加载。

created time in 2 days

push eventalibaba/termd

hengyunabc

commit sha 9d52df8fdb8488e0b73374094c9bd55616b44b72

upgrade bcpkix-jdk15on to 1.66. close #41

view details

push time in 2 days

issue closedalibaba/termd

bcpkix-jdk15on:1.54 存在多个安全漏洞,建议升级

https://github.com/alibaba/termd/blob/3b7b71f3731a582b23c4082dacd71f9e33b44a5a/pom.xml#L115-L120

bcpkix-jdk15on:1.54 存在CVE-2018-1000613、CVE-2018-1000180、CVE-2017-13098等安全漏洞 推荐升级版本: 1.66

closed time in 2 days

QiAnXinCodeSafe

issue commentalibaba/arthas

jad 查看包含lambda的类,会导致类所在进程(!!!)抛出NoClassDefFoundError

这两个issue应该是类似问题: #747 , #968 这个redefine的bug也可以参考下: https://zhuanlan.zhihu.com/p/91756092 。 jdk的bug没有太好的办法,只能升到高版本的。

处理lambda类的时候,能够忽略这个lambda类吗,至少不要影响到应用吧

jad命令实际上是触发了一次 retransform ,并没有做其它的修改。 另外,在jdk11上没有这个问题。 还有貌似不是所有有 lambda的都会出现这个问题。 所以也没办法为特定的情况处理。

Willing-Xyz

comment created time in 2 days

push eventalibaba/one-java-agent

hengyunabc

commit sha 5fbaf01eab64959b6a59b6ed86aeed1449bf55ba

add ci config

view details

push time in 3 days

push eventalibaba/one-java-agent

hengyunabc

commit sha 5c0982c1372a09d3c20fdd2904eca57a613bdf47

support init/destory

view details

hengyunabc

commit sha 6b006cad1163b92b297611e87eacfb7827e987aa

support oneagent.plugins config

view details

hengyunabc

commit sha 34802b0bf5f440bd78006ddaf194aa949fc23556

support package to zip

view details

hengyunabc

commit sha 7b53e9882a1147fbaaf67621d9b7f73f5d3013bb

support classpath/specification config, support oneagent.extPlugins config

view details

hengyunabc

commit sha 342e51de16f59e54a9204a5878cd776d52b50b8f

add demo-plugin, add testcase

view details

hengyunabc

commit sha b4cd681a7871750a424ae0e7f59105367f922840

add oneagent-logback.xml

view details

push time in 3 days

push eventalibaba/arthas

hengyunabc

commit sha 4214156579548ec9686e15b35ef560d319ff069c

update web-console.md

view details

push time in 4 days

push eventalibaba/arthas

hengyunabc

commit sha a7a1c06ecb3985592593cad60bfc1be436c970f4

Upgrade asm to 9.0 #1527

view details

push time in 4 days

issue openedalibaba/arthas

Upgrade asm to 9.0

created time in 4 days

push eventhengyunabc/arthas-repackage-deps

hengyunabc

commit sha b7bc8dd35de545cb4f44f36c5ec54ec6b4200e10

[maven-release-plugin] prepare for next development iteration

view details

push time in 4 days

push eventhengyunabc/arthas-repackage-deps

hengyunabc

commit sha 77848130cbbf94a807de49e56d21ec399d46cc0c

[maven-release-plugin] prepare release arthas-repackage-deps-0.0.6

view details

push time in 4 days

push eventhengyunabc/arthas-repackage-deps

hengyunabc

commit sha ceb7d86c111a2f117a743087664307d8e457b975

upgrade asm to 9.0

view details

push time in 4 days

issue commentalibaba/arthas

jad 查看包含lambda的类,会导致类所在进程(!!!)抛出NoClassDefFoundError

这两个issue应该是类似问题: https://github.com/alibaba/arthas/issues/747 , https://github.com/alibaba/arthas/issues/968

这个redefine的bug也可以参考下: https://zhuanlan.zhihu.com/p/91756092 。

jdk的bug没有太好的办法,只能升到高版本的。

Willing-Xyz

comment created time in 4 days

issue commentalibaba/arthas

执行trace命令抛异常,Enhancer error,java.lang.ClassFormatError: null

@hhzhong 可以测试下这个版本: https://github.com/alibaba/arthas/issues/1526#issuecomment-698320949 ,解压,cd进目录启动。

hhzhong

comment created time in 4 days

issue closedalibaba/arthas

arthas 获取spring被代理的目标对象

背景

记得一次问题排查,通过ognl 获取到 spring aop 代理过的cglib 代理对象的原始对象获取问题,spring的静态static spring context 进行调用获取被代理的目标对象的问题,记得当事是通过内部的一个工具 代理对象中被代理的目标对象 类似这个方法,通过静态的方法进行调用.挺方便的,但是这个方法比较麻烦,不是所有的工程都有这个方法,如何通过工具化让大家都能使用,这里使用 ognl 表达式进行复原整个过程,方便使用。更多使用参考 Idea Plugin,最近会把这个功能集成工具化,方便使用。

获取目标bean的命令

ognl -x 3 '#springContext=@com.xxx.util.SpringUtil@context,#springContext.getBean("BeanName")' -c 5600a5da

获取被代理的目标对象命令

ognl -x 3 '#springContext=@com.xxx.util.SpringUtil@context,#proxyBean = #springContext.getBean("BeanName"),@AopTargetUtils@getTarget(#proxyBean)' -c 5600a5da

参考文章

Ongl Lambda表达式

Ongl 官方文档 定义了一个Ongl Lambda表达式, Lambda表达式必须放在方括号内部,#this表示表达式的参数

#fib =:[#this==0 ? 0 : #this==1 ? 1 : #fib(#this-2)+#fib(#this-1)]

#fin(11)  //表示调用这个函数 计算 斐布拉基数列

Spring 获取代理对象中被代理的目标对象

代理对象中被代理的目标对象

import java.lang.reflect.Field;  

import org.springframework.aop.framework.AdvisedSupport;  
import org.springframework.aop.framework.AopProxy;  
import org.springframework.aop.support.AopUtils;  

public class AopTargetUtils {  


    /** 
     * 获取 目标对象 
     * @param proxy 代理对象 
     * @return  
     * @throws Exception 
     */  
    public static Object getTarget(Object proxy) throws Exception {  

        if(!AopUtils.isAopProxy(proxy)) {  
            return proxy; //不是代理对象  
        }  

        if(AopUtils.isJdkDynamicProxy(proxy)) {  
            return getJdkDynamicProxyTargetObject(proxy);  
        } else { //cglib  
            return getCglibProxyTargetObject(proxy);  
        }  

    }  


    private static Object getCglibProxyTargetObject(Object proxy) throws Exception {  
        Field h = proxy.getClass().getDeclaredField("CGLIB$CALLBACK_0");  
        h.setAccessible(true);  
        Object dynamicAdvisedInterceptor = h.get(proxy);  

        Field advised = dynamicAdvisedInterceptor.getClass().getDeclaredField("advised");  
        advised.setAccessible(true);  

        Object target = ((AdvisedSupport)advised.get(dynamicAdvisedInterceptor)).getTargetSource().getTarget();  

        return target;  
    }  

    private static Object getJdkDynamicProxyTargetObject(Object proxy) throws Exception {  
        Field h = proxy.getClass().getSuperclass().getDeclaredField("h");  
        h.setAccessible(true);  
        AopProxy aopProxy = (AopProxy) h.get(proxy);  

        Field advised = aopProxy.getClass().getDeclaredField("advised");  
        advised.setAccessible(true);  

        Object target = ((AdvisedSupport)advised.get(aopProxy)).getTargetSource().getTarget();  

        return target;  
    }  

}

实践获取目标对象

tt -w 执行本身使用ognl 去去处理的,类似的还有watch trace 等等

获取spring cglib的aop原始对象

tt -w '#cglibTarget =:[#hField =#this.getClass().getDeclaredField("CGLIB$CALLBACK_0"),#hField.setAccessible(true),#dynamicAdvisedInterceptor=#hField.get(#this),#fieldAdvised=#dynamicAdvisedInterceptor.getClass().getDeclaredField("advised"),#fieldAdvised.setAccessible(true),1==1? #fieldAdvised.get(#dynamicAdvisedInterceptor).getTargetSource().getTarget():null],#cglibTarget(target)'  -x 1 -i 1001

获取spring aop jdk的原始对象

tt -w '#jdkTarget=:[ #hField=#this.getClass().getSuperclass().getDeclaredField("h"),#hField.setAccessible(true),#aopProxy=#hField.get(#this),#advisedField=#aopProxy.getClass().getDeclaredField("advised"),#advisedField.setAccessible(true),1==1?#advisedField.get(#aopProxy).getTargetSource().getTarget():null],#jdkTarget(target)'  -x 1 -i 1001

当前是否为spring的Aop代理对象

tt -w '#isProxy=:[ @org.springframework.aop.support.AopUtils@isAopProxy(#this)?true:false],#isProxy(target)'  -x 1 -i 1001

当前是否为spring jdk的代理对象

tt -w '#isJdkDynamicProxy =:[@org.springframework.aop.support.AopUtils@isJdkDynamicProxy(#this) ? true :false ],#isJdkDynamicProxy(target)'  -x 1 -i 1001

结合上面的一起,获取spring 代理对象的target

tt -w '#isProxy=:[ @org.springframework.aop.support.AopUtils@isAopProxy(#this)?true:false],#isJdkDynamicProxy =:[@org.springframework.aop.support.AopUtils@isJdkDynamicProxy(#this) ? true :false ],#cglibTarget =:[#hField =#this.getClass().getDeclaredField("CGLIB$CALLBACK_0"),#hField.setAccessible(true),#dynamicAdvisedInterceptor=#hField.get(#this),#fieldAdvised=#dynamicAdvisedInterceptor.getClass().getDeclaredField("advised"),#fieldAdvised.setAccessible(true),1==1? #fieldAdvised.get(#dynamicAdvisedInterceptor).getTargetSource().getTarget():null],#jdkTarget=:[ #hField=#this.getClass().getSuperclass().getDeclaredField("h"),#hField.setAccessible(true),#aopProxy=#hField.get(#this),#advisedField=#aopProxy.getClass().getDeclaredField("advised"),#advisedField.setAccessible(true),1==1?#advisedField.get(#aopProxy).getTargetSource().getTarget():null],#nonProxyResultFunc = :[!#isProxy(#this) ? #this :#isJdkDynamicProxy(#this)? #isJdkDynamicProxy(#this) : #cglibTarget(#this)],#nonProxyTarget=#nonProxyResultFunc(target),#nonProxyTarget'  -x 1 -i 1001

纯JDK 动态代理 获取InvocationHandler

tt -w '#isProxy=:[ #this instanceof java.lang.reflect.Proxy ? @java.lang.reflect.Proxy@getInvocationHandler(#this) : #this],#isProxy(target)'  -x 1 -i 1002

结合上面所有的 如果是spring 代理对象 获取原始的对象,如果是jdk 动态代理获取InvocationHandler 否则返回target本身

tt -w '#isProxy=:[ @org.springframework.aop.support.AopUtils@isAopProxy(#this)?1: #this instanceof java.lang.reflect.Proxy ? 0 :-1],#isJdkDynamicProxy =:[@org.springframework.aop.support.AopUtils@isJdkDynamicProxy(#this) ? true :false ],#cglibTarget =:[#hField =#this.getClass().getDeclaredField("CGLIB$CALLBACK_0"),#hField.setAccessible(true),#dynamicAdvisedInterceptor=#hField.get(#this),#fieldAdvised=#dynamicAdvisedInterceptor.getClass().getDeclaredField("advised"),#fieldAdvised.setAccessible(true),1==1? #fieldAdvised.get(#dynamicAdvisedInterceptor).getTargetSource().getTarget():null],#jdkTarget=:[ #hField=#this.getClass().getSuperclass().getDeclaredField("h"),#hField.setAccessible(true),#aopProxy=#hField.get(#this),#advisedField=#aopProxy.getClass().getDeclaredField("advised"),#advisedField.setAccessible(true),1==1?#advisedField.get(#aopProxy).getTargetSource().getTarget():null],#nonProxyResultFunc = :[#proxyResul=#isProxy(#this),#proxyResul== -1 ?#this :#proxyResul== 0? @java.lang.reflect.Proxy@getInvocationHandler(#this):#isJdkDynamicProxy(#this)? #isJdkDynamicProxy(#this) : #cglibTarget(#this)],#nonProxyTarget=#nonProxyResultFunc(target),#nonProxyTarget'  -x 1 -i 1002

总结

ognl 表达式学习起来很奇妙, sc -d xxxClass 获取所有的当前类相关的类 ,然后通过jad 反编译查看 源码,这样理解一些开源框架非常方便。

closed time in 4 days

WangJi92

issue commentalibaba/arthas

当jdk 14启用 --enable-preview 时,复杂的类 watch/trace出错

原因是 .class 文件里的 java version是两部分组成的,高位是 minor ,通常是0, 低位是 major。 当启动 --enable-preview 时,编译出来的 .class 文件 的 minor version 是 65535 。 之前的代码只是简单的认为 classNode.version 就是 major version,导致出错。

hengyunabc

comment created time in 4 days

push eventalibaba/arthas

hengyunabc

commit sha 512472ed17f84f636ebc3dfa1e4c1e0c5d8d6644

Fix the problem that when the --enable-preview feature is enabled, set the wrong java version in watch/trace. #1526 #1223

view details

push time in 4 days

issue commentalibaba/arthas

当jdk 14启用 --enable-preview 时,复杂的类 watch/trace出错

options dump true ,打开dump开关,检查下生成的增强的字节码,发现

public class FFF
  minor version: 0
  major version: 49

再检查下代码,是这个commit引起的: https://github.com/alibaba/arthas/commit/25c5fb7e7b3e3b904e09bf59c66fcc2834e50f02 ,关联issue: https://github.com/alibaba/arthas/issues/1223

hengyunabc

comment created time in 4 days

issue commentalibaba/arthas

当jdk 14启用 --enable-preview 时,复杂的类 watch/trace出错

另外,加上-noverify参数,仍然会出错。

hengyunabc

comment created time in 4 days

issue commentalibaba/arthas

当jdk 14启用 --enable-preview 时,复杂的类 watch/trace出错

另外,在一个复杂的应用上,使用jdk 14,启用了 --enable-preview ,在watch时抛出下面的异常:

2020-09-24 15:38:41 [arthas-command-execute] INFO  c.t.arthas.core.advisor.Enhancer -enhance matched classes: [class com.aliyun.apsaradb.perfv4.store.dbdao.LogDbDao$$EnhancerBySpringCGLIB$$16733ee1, class com.aliyun.apsaradb.perfv4.store.dbdao.LogDbDao]
2020-09-24 15:38:41 [arthas-command-execute] ERROR c.t.arthas.core.advisor.Enhancer -Enhancer error, matchingClasses: [class com.aliyun.apsaradb.perfv4.store.dbdao.LogDbDao$$EnhancerBySpringCGLIB$$16733ee1, class com.aliyun.apsaradb.perfv4.store.dbdao.LogDbDao]
java.lang.ClassFormatError: null
        at java.instrument/sun.instrument.InstrumentationImpl.retransformClasses0(Native Method)
        at java.instrument/sun.instrument.InstrumentationImpl.retransformClasses(InstrumentationImpl.java:167)
        at com.taobao.arthas.core.advisor.Enhancer.enhance(Enhancer.java:371)
        at com.taobao.arthas.core.command.monitor200.EnhancerCommand.enhance(EnhancerCommand.java:149)
        at com.taobao.arthas.core.command.monitor200.EnhancerCommand.process(EnhancerCommand.java:96)
        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:515)
        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:1130)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630)
        at java.base/java.lang.Thread.run(Thread.java:832)

可以发现有spring aop增强的类: EnhancerBySpringCGLIB ,但和这个类无关。

因为,如果直接 watch 这个spring aop类,结果是正常的。

如果打开 options disable-sub-class true,再次 watch com.aliyun.apsaradb.perfv4.store.dbdao.LogDbDao ,则只会匹配到一个类(没有spring aop类),还是会报错。

本地未能复现,也许和上面的错误类似。

hengyunabc

comment created time in 4 days

issue openedalibaba/arthas

当jdk 14启用 --enable-preview 时,复杂的类 watch/trace出错

java.lang.UnsupportedOperationException: class redefinition failed: attempted to change the class NestHost, NestMembers, or Record attribute
        at java.instrument/sun.instrument.InstrumentationImpl.retransformClasses0(Native Method)
        at java.instrument/sun.instrument.InstrumentationImpl.retransformClasses(InstrumentationImpl.java:167)
        at com.taobao.arthas.core.advisor.Enhancer.enhance(Enhancer.java:371)
        at com.taobao.arthas.core.command.monitor200.EnhancerCommand.enhance(EnhancerCommand.java:149)
        at com.taobao.arthas.core.command.monitor200.EnhancerCommand.process(EnhancerCommand.java:96)
        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:515)
        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:1130)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630)
        at java.base/java.lang.Thread.run(Thread.java:832)

asm已升级为最新版本 9.0,并且使用了最新的API ASM9 。


复现demo:

public class BBB {
    public String test() {
        return "hello";
    }
}
public class FFF {
    public String test() {
        
        Thread t = new Thread(new Runnable() {

            @Override
            public void run() {
                System.err.println("ttt");
            }
            
        });
        t.start();
        return "hello";
    }
}
import java.io.IOException;

public class TTT {
    
    public static void main(String[] args) throws  IOException {
        
        System.err.println(new FFF());
        System.err.println(new BBB());
        System.in.read();
        
    }

}
  • 建立上面三个文件
  • 使用jdk 14来编译:jdk-14.0.2.jdk/Contents/Home/bin/javac --enable-preview --release 14 ./*.java
  • 启动: jdk-14.0.2.jdk/Contents/Home/bin/java --enable-preview TTT
  • 启动 arthas attach
  • watch BBB test ,这个是正常结果
  • watch FFF test ,会抛出上面的异常

created time in 4 days

pull request commentalibaba/arthas

fix boot error of mismatching jdk

master分支上revert掉了

kylixs

comment created time in 6 days

push eventalibaba/arthas

push time in 6 days

pull request commentalibaba/arthas

fix boot error of mismatching jdk

  1. 本质上是jdk不同版本的问题,并且也是用户当前java环境变量不一致引起的。只不过当前凑巧是成功的。不应该为一个凑巧的案例吃掉异常
  2. 可以尝试连接,但这也不是吃掉异常的理由
  3. 这个commit会被回滚
kylixs

comment created time in 6 days

pull request commentalibaba/arthas

fix boot error of mismatching jdk

实际结果是:使用不同的jdk去attach提示失败,但实际上是成功的,提示与实际结果不一致,会误导用户

本质上是一个不可知问题。如果jdk16出来,仍然抛出同样的异常,但实际上attach不成功呢?对于不可知问题,应该把现象展示,而不是吃掉异常。

kylixs

comment created time in 6 days

create barnchalibaba/arthas

branch : revert-1521-fix-boot-jdk-error

created branch time in 6 days

pull request commentalibaba/arthas

fix boot error of mismatching jdk

这种硬适配不适合加到arthas的代码里,本质是上jdk不同版本的兼容性问题。

  • 使用不同版本的jdk去attach,失败了才是正常
  • jdk不能永远保证attach这个动作是兼容的,或者永远输出一样的异常
  • jdk也不能保证输出这些异常日志后,attach还是成功的
kylixs

comment created time in 6 days

push eventalibaba/arthas

hengyunabc

commit sha f599c744085892d69554ef307205d36555e28c0a

update doc

view details

push time in 6 days

push eventalibaba/arthas

hengyunabc

commit sha e40025a2df2fe1406dee2737abcff377521bff03

[maven-release-plugin] prepare for next development iteration

view details

push time in 6 days

created tagalibaba/arthas

tagarthas-all-3.4.2

Alibaba Java Diagnostic Tool Arthas/Alibaba Java诊断利器Arthas

created time in 6 days

push eventalibaba/arthas

hengyunabc

commit sha 956a27bff8ca15c2fbf20974a8575d4332587e30

[maven-release-plugin] prepare release arthas-all-3.4.2

view details

push time in 6 days

push eventalibaba/arthas

hengyunabc

commit sha 7f16b59e2155c29d1705ab27b9c2f3e1128f202f

prepare release 3.4.2

view details

push time in 6 days

issue closedalibaba/arthas

整理arthas停止过程的代码

目前比较混乱,全部整理到 com.taobao.arthas.core.server.ArthasBootstrap.destroy() 里

closed time in 6 days

hengyunabc

issue closedalibaba/arthas

Print recommend latest version

是否应该打印在用户显示里?暂时先保守打在日志里,用户注意到可以选择升级。

closed time in 6 days

hengyunabc

push eventalibaba/arthas

gongdewei

commit sha 503e0de6b4328d8541aaabbb233bff43f7563276

improve dashboard/thread cpu time sample (#1501) * dashboard command support native thread, delta time * thread command support --all option

view details

push time in 6 days

PR merged alibaba/arthas

improve dashboard/thread cpu time sample
  • Improve dashboard/thread cpu usage stats, similar to linux top command
  • Support JVM internal threads (gc/JIT compilation, etc.)
  • Display cpu delta time (delta_time), improve cpu usage accuracy
  • Display all thread results with option '--all'
  • Fix thread/dashboard command jdk6 compatible

Cpu usage and delta time calculation:
sampleIntervalTime = newSampleTime - lastSampleTime threadDeltaCpuTime = newThreadCpuTime - lastThreadCpuTime cpuUsage = threadDeltaCpuTime / sampleIntervalTime

+1196 -612

5 comments

24 changed files

kylixs

pr closed time in 6 days

push eventalibaba/arthas

gongdewei

commit sha 4d06126b763255d5c2b2b2be3a8515f2840ef437

Improve arthas stop logic (#1513, #1514) (#1517)

view details

push time in 6 days

PR merged alibaba/arthas

Improve arthas stop logic (#1513, #1514)

fix issues: https://github.com/alibaba/arthas/issues/1514 https://github.com/alibaba/arthas/issues/1513

  • Improve arthas stop logic, fix #1513
  • Clean resources when http port bind failed
+33 -40

0 comment

4 changed files

kylixs

pr closed time in 6 days

issue closedalibaba/arthas

3.3.4 版本后,没有办法干净地停止 arthas

在3.3.4版本之前,arthas自身是可以干净停止掉。比如使用 3.3.3

./as.sh --use-version 3.3.3

再执行 stop命令退出。

多次执行之后,再执行 classloader -l 命令,可以看到多个 Arthas ClassLoader:

[arthas@26595]$ classloader -l
 name                                                         loadedCount  hash      parent
 BootstrapClassLoader                                         2282         null      null
 com.taobao.arthas.agent.ArthasClassloader@2e057810           1234         2e057810  sun.misc.Launcher$ExtClassLoader@135fbaa4
 com.taobao.arthas.agent.ArthasClassloader@1c17942d           1234         1c17942d  sun.misc.Launcher$ExtClassLoader@135fbaa4
 com.taobao.arthas.agent.ArthasClassloader@53ba2af0           1235         53ba2af0  sun.misc.Launcher$ExtClassLoader@135fbaa4
 com.taobao.arthas.agent.ArthasClassloader@5082542d           1201         5082542d  sun.misc.Launcher$ExtClassLoader@135fbaa4
 javax.management.remote.rmi.NoCallStackClassLoader@57280b08  1            57280b08  null
 javax.management.remote.rmi.NoCallStackClassLoader@38df0b4   1            38df0b4   null
 sun.misc.Launcher$AppClassLoader@232204a1                    4            232204a1  sun.misc.Launcher$ExtClassLoader@135fbaa4
 sun.misc.Launcher$ExtClassLoader@135fbaa4                    4            135fbaa4  null
 sun.reflect.misc.MethodUtil@4e685d1f                         1            4e685d1f  sun.misc.Launcher$AppClassLoader@232204a1
Affect(row-cnt:10) cost in 6 ms.

打到jvisualvm ,然后执行 heapdump:

image

执行完之后,再执行 classloader -l,可以发现只剩下一个Arthas ClassLoader:

[arthas@26595]$ classloader -l
 name                                                         loadedCount  hash      parent
 BootstrapClassLoader                                         2311         null      null
 com.taobao.arthas.agent.ArthasClassloader@5082542d           1208         5082542d  sun.misc.Launcher$ExtClassLoader@135fbaa4
 javax.management.remote.rmi.NoCallStackClassLoader@57280b08  1            57280b08  null
 javax.management.remote.rmi.NoCallStackClassLoader@38df0b4   1            38df0b4   null
 sun.misc.Launcher$AppClassLoader@232204a1                    4            232204a1  sun.misc.Launcher$ExtClassLoader@135fbaa4
 sun.misc.Launcher$ExtClassLoader@135fbaa4                    4            135fbaa4  null
 sun.reflect.misc.MethodUtil@4e685d1f                         1            4e685d1f  sun.misc.Launcher$AppClassLoader@232204a1
Affect(row-cnt:7) cost in 5 ms.

说明之前启动的 arthas都被回收掉了。

但是在 3.3.4 版本之后,Arthas ClassLoder没办法被回收。

closed time in 6 days

hengyunabc

push eventkylixs/arthas

hengyunabc

commit sha 402a7e223e07e4ba52cffe5c9584b6713b6b0749

Update ArthasBootstrap.java

view details

push time in 6 days

pull request commentalibaba/arthas

improve dashboard/thread cpu time sample

最新的代码会出现打印 TIME 不对的问题,第一次dashboard输出结果会出现:

image

应该是第一次输出结果时, 出现了负数。

kylixs

comment created time in 6 days

PullRequestReviewEvent

Pull request review commentalibaba/arthas

improve dashboard/thread cpu time sample

 dashboard  ``` $ dashboard-ID         NAME                              GROUP                  PRIORITY   STATE       %CPU       TIME       INTERRUPTED DAEMON-889        RMI TCP Connection(15)-30.10.166. RMI Runtime            9          RUNNABLE    48         0:5        false       true-1077       Timer-for-arthas-dashboard-0      system                 9          RUNNABLE    24         0:0        false       true-1074       as-selector-daemon                system                 9          RUNNABLE    12         0:0        false       true-284        JMX server connection timeout 284 RMI Runtime            9          TIMED_WAITI 8          0:3        false       true-16         Timer-1                           main                   5          TIMED_WAITI 5          0:9        false       true-47         Pandora pandora-qos-reporter Pool main                   5          TIMED_WAITI 0          0:0        false       true-48         JmonitorClient-CheckThread Pool [ main                   5          TIMED_WAITI 0          0:0        false       true-49         JmonitorClient-HeartBeat Pool [Th main                   5          TIMED_WAITI 0          0:0        false       true-50         JmonitorClient-ReaderThread Pool  main                   5          TIMED_WAITI 0          0:0        false       true-957        RMI TCP Connection(16)-30.10.166. RMI Runtime            9          RUNNABLE    0          0:2        false       true-51         JmonitorClient-WriterThread Pool  main                   5          TIMED_WAITI 0          0:0        false       true-52         ContainerBackgroundProcessor[Stan main                   5          TIMED_WAITI 0          0:0        false       true-53         http-bio-8080-Acceptor-0          main                   5          RUNNABLE    0          0:2        false       true-54         http-bio-8080-AsyncTimeout        main                   5          TIMED_WAITI 0          0:0        false       true-11         GC Daemon                         system                 2          TIMED_WAITI 0          0:0        false       true-Memory                       used      total     max      usage     GC-heap                         59M       223M      1820M    3.26%     gc.ps_scavenge.count              118-ps_eden_space                14M       114M      668M     2.11%     gc.ps_scavenge.time(ms)           1890-ps_survivor_space            6M        6M        6M       96.08%    gc.ps_marksweep.count             5-ps_old_gen                   39M       103M      1365M    2.86%     gc.ps_marksweep.time(ms)          1140-nonheap                      234M      240M      0M       97.46%-code_cache                   46M       47M       240M     19.49%-metaspace                    167M      172M      0M       97.36%-Runtime                                                             Tomcat-os.name                           Mac OS X                          connector                         http-bio-8080-os.version                        10.10.5                           QPS                               0.00-java.version                      1.8.0_60                          RT(ms)                            1.13-java.home                                                           error/s                           0.00-                                                                    received/s                        0B-systemload.average                3.44                              sent/s                            0B-processors                        4                                 threadpool                        http-bio-8080-uptime                            16020s                            busy                              0+ID   NAME                           GROUP           PRIORITY   STATE     %CPU      DELTA_TIME TIME      INTERRUPTE DAEMON+-1   C2 CompilerThread0             -               -1         -         1.55      0.077      0:8.684   false      true+53   Timer-for-arthas-dashboard-07b system          5          RUNNABLE  0.08      0.004      0:0.004   false      true+22   scheduling-1                   main            5          TIMED_WAI 0.06      0.003      0:0.287   false      false+-1   C1 CompilerThread0             -               -1         -         0.06      0.003      0:2.171   false      true+-1   VM Periodic Task Thread        -               -1         -         0.03      0.001      0:0.092   false      true+49   arthas-NettyHttpTelnetBootstra system          5          RUNNABLE  0.02      0.001      0:0.156   false      true+16   Catalina-utility-1             main            1          TIMED_WAI 0.0       0.000      0:0.029   false      false+-1   G1 Young RemSet Sampling       -               -1         -         0.0       0.000      0:0.019   false      true+17   Catalina-utility-2             main            1          WAITING   0.0       0.000      0:0.025   false      false+34   http-nio-8080-ClientPoller     main            5          RUNNABLE  0.0       0.000      0:0.016   false      true+23   http-nio-8080-BlockPoller      main            5          RUNNABLE  0.0       0.000      0:0.011   false      true+-1   VM Thread                      -               -1         -         0.0       0.000      0:0.032   false      true+-1   Service Thread                 -               -1         -         0.0       0.000      0:0.006   false      true+-1   GC Thread#5                    -               -1         -         0.0       0.000      0:0.043   false      true+Memory                     used     total    max      usage    GC+heap                       36M      70M      4096M    0.90%    gc.g1_young_generation.count   12+g1_eden_space              6M       18M      -1       33.33%                                  86+g1_old_gen                 30M      50M      4096M    0.74%    gc.g1_old_generation.count     0+g1_survivor_space          491K     2048K    -1       24.01%   gc.g1_old_generation.time(ms)  0+nonheap                    66M      69M      -1       96.56%+codeheap_'non-nmethods'    1M       2M       5M       22.39%+metaspace                  46M      47M      -1       98.01%+Runtime+os.name                                                        Mac OS X+os.version                                                     10.15.4+java.version                                                   15+java.home                                                      /Library/Java/JavaVirtualMachines/jdk-15.jdk/Contents/Home+systemload.average                                             10.68+processors                                                     8+uptime                                                         272s ```  ### 数据说明 -* ID: Java级别的线程ID,注意这个ID不能跟jstack中的nativeID一一对应+* ID: Java级别的线程ID,注意这个ID不能跟jstack中的nativeID一一对应。 * NAME: 线程名 * GROUP: 线程组名 * PRIORITY: 线程优先级, 1~10之间的数字,越大表示优先级越高 * STATE: 线程的状态-* CPU%: 线程消耗的cpu占比,采样100ms,将所有线程在这100ms内的cpu使用量求和,再算出每个线程的cpu使用占比。-* TIME: 线程运行总时间,数据格式为`分:秒`+* CPU%: 线程的cpu使用率。比如采样间隔1000ms,某个线程的增量cpu时间为100ms,则cpu使用率=100/1000=10%+* DELTA_TIME: 上次采样之后线程运行增量CPU时间,数据格式为`秒.毫秒`+* TIME: 线程运行总CPU时间,数据格式为`分:秒.毫秒`

同上,应该是 分:秒

kylixs

comment created time in 6 days

Pull request review commentalibaba/arthas

improve dashboard/thread cpu time sample

 dashboard  ``` $ dashboard-ID         NAME                              GROUP                  PRIORITY   STATE       %CPU       TIME       INTERRUPTED DAEMON-889        RMI TCP Connection(15)-30.10.166. RMI Runtime            9          RUNNABLE    48         0:5        false       true-1077       Timer-for-arthas-dashboard-0      system                 9          RUNNABLE    24         0:0        false       true-1074       as-selector-daemon                system                 9          RUNNABLE    12         0:0        false       true-284        JMX server connection timeout 284 RMI Runtime            9          TIMED_WAITI 8          0:3        false       true-16         Timer-1                           main                   5          TIMED_WAITI 5          0:9        false       true-47         Pandora pandora-qos-reporter Pool main                   5          TIMED_WAITI 0          0:0        false       true-48         JmonitorClient-CheckThread Pool [ main                   5          TIMED_WAITI 0          0:0        false       true-49         JmonitorClient-HeartBeat Pool [Th main                   5          TIMED_WAITI 0          0:0        false       true-50         JmonitorClient-ReaderThread Pool  main                   5          TIMED_WAITI 0          0:0        false       true-957        RMI TCP Connection(16)-30.10.166. RMI Runtime            9          RUNNABLE    0          0:2        false       true-51         JmonitorClient-WriterThread Pool  main                   5          TIMED_WAITI 0          0:0        false       true-52         ContainerBackgroundProcessor[Stan main                   5          TIMED_WAITI 0          0:0        false       true-53         http-bio-8080-Acceptor-0          main                   5          RUNNABLE    0          0:2        false       true-54         http-bio-8080-AsyncTimeout        main                   5          TIMED_WAITI 0          0:0        false       true-11         GC Daemon                         system                 2          TIMED_WAITI 0          0:0        false       true-Memory                       used      total     max      usage     GC-heap                         59M       223M      1820M    3.26%     gc.ps_scavenge.count              118-ps_eden_space                14M       114M      668M     2.11%     gc.ps_scavenge.time(ms)           1890-ps_survivor_space            6M        6M        6M       96.08%    gc.ps_marksweep.count             5-ps_old_gen                   39M       103M      1365M    2.86%     gc.ps_marksweep.time(ms)          1140-nonheap                      234M      240M      0M       97.46%-code_cache                   46M       47M       240M     19.49%-metaspace                    167M      172M      0M       97.36%-Runtime                                                             Tomcat-os.name                           Mac OS X                          connector                         http-bio-8080-os.version                        10.10.5                           QPS                               0.00-java.version                      1.8.0_60                          RT(ms)                            1.13-java.home                                                           error/s                           0.00-                                                                    received/s                        0B-systemload.average                3.44                              sent/s                            0B-processors                        4                                 threadpool                        http-bio-8080-uptime                            16020s                            busy                              0+ID   NAME                           GROUP           PRIORITY   STATE     %CPU      DELTA_TIME TIME      INTERRUPTE DAEMON+-1   C2 CompilerThread0             -               -1         -         1.55      0.077      0:8.684   false      true+53   Timer-for-arthas-dashboard-07b system          5          RUNNABLE  0.08      0.004      0:0.004   false      true+22   scheduling-1                   main            5          TIMED_WAI 0.06      0.003      0:0.287   false      false+-1   C1 CompilerThread0             -               -1         -         0.06      0.003      0:2.171   false      true+-1   VM Periodic Task Thread        -               -1         -         0.03      0.001      0:0.092   false      true+49   arthas-NettyHttpTelnetBootstra system          5          RUNNABLE  0.02      0.001      0:0.156   false      true+16   Catalina-utility-1             main            1          TIMED_WAI 0.0       0.000      0:0.029   false      false+-1   G1 Young RemSet Sampling       -               -1         -         0.0       0.000      0:0.019   false      true+17   Catalina-utility-2             main            1          WAITING   0.0       0.000      0:0.025   false      false+34   http-nio-8080-ClientPoller     main            5          RUNNABLE  0.0       0.000      0:0.016   false      true+23   http-nio-8080-BlockPoller      main            5          RUNNABLE  0.0       0.000      0:0.011   false      true+-1   VM Thread                      -               -1         -         0.0       0.000      0:0.032   false      true+-1   Service Thread                 -               -1         -         0.0       0.000      0:0.006   false      true+-1   GC Thread#5                    -               -1         -         0.0       0.000      0:0.043   false      true+Memory                     used     total    max      usage    GC+heap                       36M      70M      4096M    0.90%    gc.g1_young_generation.count   12+g1_eden_space              6M       18M      -1       33.33%                                  86+g1_old_gen                 30M      50M      4096M    0.74%    gc.g1_old_generation.count     0+g1_survivor_space          491K     2048K    -1       24.01%   gc.g1_old_generation.time(ms)  0+nonheap                    66M      69M      -1       96.56%+codeheap_'non-nmethods'    1M       2M       5M       22.39%+metaspace                  46M      47M      -1       98.01%+Runtime+os.name                                                        Mac OS X+os.version                                                     10.15.4+java.version                                                   15+java.home                                                      /Library/Java/JavaVirtualMachines/jdk-15.jdk/Contents/Home+systemload.average                                             10.68+processors                                                     8+uptime                                                         272s ```  ### 数据说明 -* ID: Java级别的线程ID,注意这个ID不能跟jstack中的nativeID一一对应+* ID: Java级别的线程ID,注意这个ID不能跟jstack中的nativeID一一对应。 * NAME: 线程名 * GROUP: 线程组名 * PRIORITY: 线程优先级, 1~10之间的数字,越大表示优先级越高 * STATE: 线程的状态-* CPU%: 线程消耗的cpu占比,采样100ms,将所有线程在这100ms内的cpu使用量求和,再算出每个线程的cpu使用占比。-* TIME: 线程运行总时间,数据格式为`分:秒`+* CPU%: 线程的cpu使用率。比如采样间隔1000ms,某个线程的增量cpu时间为100ms,则cpu使用率=100/1000=10%+* DELTA_TIME: 上次采样之后线程运行增量CPU时间,数据格式为`秒.毫秒`

这里的说明不对,应该直接是 单位是秒?

kylixs

comment created time in 6 days

PullRequestReviewEvent

Pull request review commentalibaba/arthas

Improve arthas stop logic (#1513, #1514)

 private void bind(Configure configure) throws Throwable {              logger().info("as-server started in {} ms", System.currentTimeMillis() - start);         } catch (Throwable e) {-            logger().error("Error during bind to port " + configure.getTelnetPort(), e);-            if (shellServer != null) {-                shellServer.close();-            }-            if (sessionManager != null){-                sessionManager.close();-            }-            shutdownWorkGroup();+            logger().error("Error during start as-server", e);+            destroy();

原来的代码有调用 shutdownWorkGroup(),新的代码没有

kylixs

comment created time in 6 days

Pull request review commentalibaba/arthas

Improve arthas stop logic (#1513, #1514)

 public static void agentmain(String args, Instrumentation inst) {     /**      * 让下次再次启动时有机会重新加载      */-    public synchronized static void resetArthasClassLoader() {+    public static void resetArthasClassLoader() {+        //不能使用main函数相同的锁对象,避免启动失败清理资源时死锁

//不能使用main函数相同的锁对象,避免启动失败清理资源时死锁

这行应该删掉

kylixs

comment created time in 6 days

Pull request review commentalibaba/arthas

Improve arthas stop logic (#1513, #1514)

 private void bind(Configure configure) throws Throwable {             }              shellServer.listen(new BindHandler(isBindRef));+            if (!isBind()) {+                throw new RuntimeException("some ports bind failed");

这个异常信息不清楚。 另外,可以用 IllegalStateException

kylixs

comment created time in 6 days

PullRequestReviewEvent
PullRequestReviewEvent

Pull request review commentalibaba/arthas

Improve arthas stop logic (#1513, #1514)

 private static ClassLoader getClassLoader(Instrumentation inst, File arthasCoreJ     }      private static ClassLoader loadOrDefineClassLoader(File arthasCoreJarFile) throws Throwable {-        if (arthasClassLoader == null) {-            arthasClassLoader = new ArthasClassloader(new URL[]{arthasCoreJarFile.toURI().toURL()});+        synchronized (arthasClassLoaderLock) {+            if (arthasClassLoader == null) {+                arthasClassLoader = new ArthasClassloader(new URL[]{arthasCoreJarFile.toURI().toURL()});

应该在 synchronized 块外面,加一块 if(arthasClassLoader != null) return arthasClassLoader;

kylixs

comment created time in 7 days

Pull request review commentalibaba/arthas

Improve arthas stop logic (#1513, #1514)

 private static ClassLoader getClassLoader(Instrumentation inst, File arthasCoreJ     }      private static ClassLoader loadOrDefineClassLoader(File arthasCoreJarFile) throws Throwable {-        if (arthasClassLoader == null) {-            arthasClassLoader = new ArthasClassloader(new URL[]{arthasCoreJarFile.toURI().toURL()});+        synchronized (arthasClassLoaderLock) {

直接 synchronized(AgentBootstrap.class) 就可以了。

kylixs

comment created time in 7 days

Pull request review commentalibaba/arthas

Improve arthas stop logic (#1513, #1514)

 public static void agentmain(String args, Instrumentation inst) {     /**      * 让下次再次启动时有机会重新加载      */-    public synchronized static void resetArthasClassLoader() {-        arthasClassLoader = null;+    public static void resetArthasClassLoader() {+        //不能使用main函数相同的锁对象,避免启动失败清理资源时死锁+        synchronized (arthasClassLoaderLock) {

这里没必要加锁,是否加锁不影响执行结果

kylixs

comment created time in 7 days

PullRequestReviewEvent
PullRequestReviewEvent
more