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

Posted wesleyshare

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Can't attach to the process: ptrace(PTRACE_ATTACH, ..)相关的知识,希望对你有一定的参考价值。

PC : ubuntu 16.04

jdk : 1.8.0_144

当我想查看线程堆栈信息的时候,出现了如下异常:

[email protected]:~$ jstack -F 7566

××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××

Attaching to process ID 7566, please wait...
Error attaching to process: sun.jvm.hotspot.debugger.DebuggerException: Can‘t attach to the process: ptrace(PTRACE_ATTACH, ..) failed for 7566: 不允许的操作
sun.jvm.hotspot.debugger.DebuggerException: sun.jvm.hotspot.debugger.DebuggerException: Can‘t attach to the process: ptrace(PTRACE_ATTACH, ..) failed for 7566: 不允许的操作
    at sun.jvm.hotspot.debugger.linux.LinuxDebuggerLocal$LinuxDebuggerLocalWorkerThread.execute(LinuxDebuggerLocal.java:163)
    at sun.jvm.hotspot.debugger.linux.LinuxDebuggerLocal.attach(LinuxDebuggerLocal.java:278)
    at sun.jvm.hotspot.HotSpotAgent.attachDebugger(HotSpotAgent.java:671)
    at sun.jvm.hotspot.HotSpotAgent.setupDebuggerLinux(HotSpotAgent.java:611)
    at sun.jvm.hotspot.HotSpotAgent.setupDebugger(HotSpotAgent.java:337)
    at sun.jvm.hotspot.HotSpotAgent.go(HotSpotAgent.java:304)
    at sun.jvm.hotspot.HotSpotAgent.attach(HotSpotAgent.java:140)
    at sun.jvm.hotspot.tools.Tool.start(Tool.java:185)
    at sun.jvm.hotspot.tools.Tool.execute(Tool.java:118)
    at sun.jvm.hotspot.tools.JStack.main(JStack.java:92)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at sun.tools.jstack.JStack.runJStackTool(JStack.java:140)
    at sun.tools.jstack.JStack.main(JStack.java:106)
Caused by: sun.jvm.hotspot.debugger.DebuggerException: Can‘t attach to the process: ptrace(PTRACE_ATTACH, ..) failed for 7566: 不允许的操作
    at sun.jvm.hotspot.debugger.linux.LinuxDebuggerLocal.attach0(Native Method)
    at sun.jvm.hotspot.debugger.linux.LinuxDebuggerLocal.access$100(LinuxDebuggerLocal.java:62)
    at sun.jvm.hotspot.debugger.linux.LinuxDebuggerLocal$1AttachTask.doit(LinuxDebuggerLocal.java:269)
    at sun.jvm.hotspot.debugger.linux.LinuxDebuggerLocal$LinuxDebuggerLocalWorkerThread.run(LinuxDebuggerLocal.java:138)

××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××

解决方法:

  echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope

原因:见参考文档

拓展内容:ptrace_scope

参考文档:

  1. http://gaofu1986.blog.163.com/blog/static/836012420150104137592/
  2. https://www.cnblogs.com/wscit/p/6803354.html

 
























以上是关于Can't attach to the process: ptrace(PTRACE_ATTACH, ..)的主要内容,如果未能解决你的问题,请参考以下文章

CentOS8安装pycharm报错Can't connect to X11 window server using ':0' as the value of the DIS(

Can't connect to X11 window server using ':1.0' as the value of the DISPLAY variable.(示例

Nagios-报错:UNKNOWN Can't connect to the JVM:

MacOS svn:E230001 Can't use Subversion command line client: svn The path to the Subversion execu

There was a problem connecting to the database server. The following error had occured: Can't co

How to solve the problem that Github can't visit in China?