-
Notifications
You must be signed in to change notification settings - Fork 7.5k
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
arthas 执行报错 断点调试arthas 代码- StackOverflowError #1610
Comments
上面的说明少了一步,要先执行 |
是滴,少写了一步 |
根因分析及修复方法这里出错的根因是 方法递归调用,最终造成 StackOverflowError 下面这行代码导致了递归调用,把线程名这里修改下,就可以执行成功了,解决问题的方法是这个,但是从功能上看, trace 类 java.lang.Thread 的 getName() 算是一个比较少见的场景,wiki 上说明下,不是非常有必要修复 修改前
修改后 threadNode.setThreadName("aa"); 递归调用路径如图: 复现 debug 建议arthas 建议断点位置arthas/core/src/main/java/com/taobao/arthas/core/command/monitor200/EnhancerCommand.java Line 149 in d9151ed
执行完下面这行代码就会出现了
测试 Demo 代码片段public class Demo {
static class Counter {
private static AtomicInteger count = new AtomicInteger(0);
public static void increment() {
count.incrementAndGet();
}
public static int value() {
return count.get();
}
}
public static void main(String[] args) {
while (true) {
Thread testThread1 = new Thread(new Runnable() {
@Override
public void run() {
System.out.println(Thread.currentThread().getName() +
"counter: " + Counter.value());
}
});
Counter.increment();
testThread1.setName("favoorr-test-thread" + Counter.value());
testThread1.start();
System.out.println(testThread1.getName());
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
testThread1 = null;
}
}
} Bug 修复后正确执行示例
|
环境信息
arthas-boot.jar
或者as.sh
的版本:1.1 发现问题
使用arthas 执行一个 trace java.lang.Thread
响应信息
错误日志
1.2 我调试一下arthas的代码?
1.2.1 启动demo
1.2.2 启动arthas
https://arthas.aliyun.com/doc/install-detail.html
as.sh 直接启动
1.2.3 下载arthas 最新代码
1.2.4 arthas 工程直接一个remote debug
1.2.5 通过错误代码debug
com.taobao.arthas.core.shell.system.impl.ProcessImpl.CommandProcessImpl#appendResult
小技巧打印堆栈
找到入口
com.taobao.arthas.core.shell.handlers.term.RequestHandler#accept
com.taobao.arthas.core.shell.system.impl.JobImpl#run(boolean)
com.taobao.arthas.core.shell.system.impl.ProcessImpl#run(boolean)
com.taobao.arthas.core.shell.system.impl.ProcessImpl.CommandProcessTask#run
com.taobao.arthas.core.shell.handlers.Handler#handle
com.taobao.arthas.core.shell.command.impl.AnnotatedCommandImpl#process
com.taobao.arthas.core.command.monitor200.EnhancerCommand#process
com.taobao.arthas.core.command.monitor200.EnhancerCommand#enhance
1.3 跟踪问题
com.taobao.arthas.core.command.monitor200.EnhancerCommand#enhance
代码增强是ok的
增强的反馈
不知道什么时候 变为 终结状态的。
查看到异常、但是日志好像没有看到
com.taobao.arthas.core.command.monitor200.AbstractTraceAdviceListener#finishing
Method threw 'java.lang.StackOverflowError' exception. Cannot evaluate java.lang.Thread.toString()
日志里面没有搜索到 StackOverflowError
The text was updated successfully, but these errors were encountered: