首页 > 其他分享 >mac 下 Can't attach to the process. Could be caused by an incorrect pid or lack of privileges. 解

mac 下 Can't attach to the process. Could be caused by an incorrect pid or lack of privileges. 解

时间:2024-02-02 18:55:06浏览次数:20  
标签:incorrect java jdk process sun hotspot agent jvm caused

问题

报错如下

ERROR: attach: task_for_pid(4060) failed: '(os/kern) failure' (5)
Error attaching to process: Can't attach to the process. Could be caused by an incorrect pid or lack of privileges.
sun.jvm.hotspot.debugger.DebuggerException: Can't attach to the process. Could be caused by an incorrect pid or lack of privileges.
at jdk.hotspot.agent/sun.jvm.hotspot.debugger.bsd.BsdDebuggerLocal$BsdDebuggerLocalWorkerThread.execute(BsdDebuggerLocal.java:168)
at jdk.hotspot.agent/sun.jvm.hotspot.debugger.bsd.BsdDebuggerLocal.attach(BsdDebuggerLocal.java:282)
at jdk.hotspot.agent/sun.jvm.hotspot.HotSpotAgent.attachDebugger(HotSpotAgent.java:648)
at jdk.hotspot.agent/sun.jvm.hotspot.HotSpotAgent.setupDebuggerDarwin(HotSpotAgent.java:636)
at jdk.hotspot.agent/sun.jvm.hotspot.HotSpotAgent.setupDebugger(HotSpotAgent.java:371)
at jdk.hotspot.agent/sun.jvm.hotspot.HotSpotAgent.go(HotSpotAgent.java:336)
at jdk.hotspot.agent/sun.jvm.hotspot.HotSpotAgent.attach(HotSpotAgent.java:141)
at jdk.hotspot.agent/sun.jvm.hotspot.tools.Tool.start(Tool.java:203)
at jdk.hotspot.agent/sun.jvm.hotspot.tools.Tool.execute(Tool.java:134)
at com.serveree.uselesscode.SAMethodDemo_jdk17.main(SAMethodDemo_jdk17.java:34)
Caused by: sun.jvm.hotspot.debugger.DebuggerException: Can't attach to the process. Could be caused by an incorrect pid or lack of privileges.
at jdk.hotspot.agent/sun.jvm.hotspot.debugger.bsd.BsdDebuggerLocal.attach0(Native Method)
at jdk.hotspot.agent/sun.jvm.hotspot.debugger.bsd.BsdDebuggerLocal\(1AttachTask.doit(BsdDebuggerLocal.java:273) at jdk.hotspot.agent/sun.jvm.hotspot.debugger.bsd.BsdDebuggerLocal\)BsdDebuggerLocalWorkerThread.run(BsdDebuggerLocal.java:143)

原因

应该是 mac 间进程通信的问题,导致 java 程序缺少必要的权限

解决

有两种解决方法

命令行执行命令前加上 sudo

使用 sudo 运行 java 程序能够给它必要的权限

禁用 mac 的 SIP(System Integrity Protection, 系统完整性保护)

参考:https://blog.csdn.net/gusijin/article/details/126677058

注意: intel芯片的 mac 进入安全模式的方法与 m 系列芯片 mac 不同,intel 芯片为亮屏后长按 command + R

标签:incorrect,java,jdk,process,sun,hotspot,agent,jvm,caused
From: https://www.cnblogs.com/shixuanliu/p/18003681

相关文章

  • 编译时process_begin: CreateProcess | mutex/condition_variable 报错的一种解决办法
    系统:win10目的:想跑一下wisper.cpp前置操作:把该项目git下来后打算make,一make就报错注意,图里其实有两种错误,第一种是process_begin:CreateProcess(NULL,xxx)failed,第二种是error:'thread'isnotamemberof'std'.第二种错误是因为mingw不支持thread库,但是官方有给过补丁,可......
  • jmeter 使用 BeanShell PostProcessor 过程中遇到的一些问题记录
    关于jmeter中使用BeanShellPostProcessor遇到的一些问题记录:1、BeanShellPostProcessor的位置BeanShellPostProcessor要放在获取内容对应的线程的同一个层级,如:2、内容:例如:FileWriterfstream=newFileWriter("E:\aaskNodeId.csv");//,如果要建立文件并追加写入数据,需......
  • tomcat启动时报错:Caused by: java.lang.IllegalArgumentException: AJP连接器配置secr
    31-Jan-202414:01:13.812信息[main]org.apache.coyote.AbstractProtocol.start开始协议处理句柄["http-nio-8080"]31-Jan-202414:01:13.818严重[main]org.apache.catalina.core.StandardService.startInternalFailedtostartconnector[Connector[AJP/1.3-8009]]......
  • 解决MySQL设置时区时的错误Unknown or incorrect time zone: 'Asia/Shanghai'
    问题描述:在trino中配置了mysql.properties文件,但是通过trino客户端,执行命令showschemasfrommysql;查看数据库信息时报错:Errorlistingschemasforcatalogmysql:java.sql.SQLNonTransientConnectionException:Couldnotcreateconnectiontodatabaseserver.Attempted......
  • C# 守护控制台进程(process)
    C#通过Process和list配合不断检测进程并重启该进程使用语言:C#环境:.netFramework4.6.1(当前使用)(貌似支持所有环境,我就不多说了)usingSystem;usingSystem.Collections.Generic;usingSystem.Diagnostics;usingSystem.Linq;usingSystem.Text;usingSystem.Threadi......
  • WorkFlow,Process,Job,Task各详细解释和他们的区别
    来自你的消息:请详细解释WorkFlow,Process,Job,Task各详细解释和他们的区别来自WeTabAI的消息:当谈到工作流程(Workflow),流程(Process),任务(Job)和任务(Task)时,它们在企业管理和信息技术领域中有不同的含义和用法。下面是它们的详细解释和区别:工作流程(Workflow):工作流程是一系列有序的......
  • Understanding the linux kernel Chapter3 Processes
    ProcessDescriptorHowProcessesAreOrganizedtheprocessinstate:TASK_RUNNINGorganizedinrunqueuelistgroupTASK_STROPPED\EXIT_ZOMBIE\EXIT_DEADThereisnoneedtogroupprocessesinanyofthesethreestates,becausestopped,zombie,andd......
  • Qt开发程序用QProcess调用curl命令上传文件并获取响应的文件
    1.需求做一个批量数字签名的工具,从一个文件夹内寻找所有的exe文件,然后复制到另外一个文件夹中,并且保存源文件的路径,将目标文件夹内的所有exe文件上传到公司的数字签名平台去做数字签名,并且返回接收后的文件;尝试了libcurl的post请求,发现总是返回参数错误; intHttpClient::Po......
  • 神经网络优化篇:详解调试处理(Tuning process)
    调试处理关于训练深度最难的事情之一是要处理的参数的数量,从学习速率\(a\)到Momentum(动量梯度下降法)的参数\(\beta\)。如果使用Momentum或Adam优化算法的参数,\(\beta_{1}\),\({\beta}_{2}\)和\(\varepsilon\),也许还得选择层数,也许还得选择不同层中隐藏单元的数量,也许还想使用学习......
  • python 多线程multiprocessing
    该多线程,简单计算结果可以使用,在django里想并行处理多个实体进行计算不行,请自行验证importmultiprocessing#要在进程池中并行执行的任务函数defprocess_data(data):#执行任务的逻辑result=data*2returnresultif__name__=='__main__':#创......