Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
347 views
in Technique[技术] by (71.8m points)

Can't attach to the process: ptrace(PTRACE_ATTACH, ..)

### 问题描述
使用ptrace工具和JDK中的jinfo jmap都无法使用
### 问题出现的平台版本及自己尝试过哪些方法
OS:ubuntu20.4
尝试方法:
1.修改kernel.yama.ptrace_scope = 0
2.切换root用户进行测试
### 相关代码
粘贴代码文本(请勿用截图)
root@ubuntu:/home/jition/IdeaProjects/jvmitem# jps
2625 Launcher
6466 Jps
2364 Main

root@ubuntu:/home/jition/IdeaProjects/jvmitem# strace -p 2364
strace: Could not attach to process. If your uid matches the uid of the target process, check the setting of /proc/sys/kernel/yama/ptrace_scope, or try again as the root user. For more details, see /etc/sysctl.d/10-ptrace.conf: 不允操作
strace: attach: ptrace(PTRACE_SEIZE, 2364): 不允许的操作

root@ubuntu:/home/jition/IdeaProjects/jvmitem# jinfo 2364
Attaching to process ID 2364, please wait...
Error attaching to process: sun.jvm.hotspot.debugger.DebuggerException: Can't attach to the process: ptrace(PTRACE_ATTACH, ..) failed for 2364: 不允许的操作
sun.jvm.hotspot.debugger.DebuggerException: sun.jvm.hotspot.debugger.DebuggerException: Can't attach to the process: ptrace(PTRACE_ATTACH, ..) failed for 2364: 不允许的操作

ubuntu20.4版本的已经修改了,还是无效
root@ubuntu:/home/jition/IdeaProjects/jvmitem# cat /proc/sys/kernel/yama/ptrace_scope
0

### 你期待的结果是什么?实际看到的错误信息又是什么?
Can't attach to the process: ptrace(PTRACE_ATTACH, ..)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神解答

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...