Could not attach to pid:#### this could be caused by a kernel security setting, try writing "0" to /proc/sys/kernel/yama/ptrace_scope

63 views
Skip to first unread message

Anjana Prabhakar

unread,
Mar 13, 2020, 3:45:57 AM3/13/20
to golang-nuts
Hi All,

I am trying to use the debug with attach option of VSCode using Go extension. The application based on go that is running is the tendermint blockchain network. on using the run and debug with attach option, I get the following error "

Could not attach to pid:#### this could be caused by a kernel security setting, try writing "0" to /proc/sys/kernel/yama/ptrace_scope"


the launch.json file configuration i use is:
"name":"attach to process",
            "type": "go",
            "request": "attach",
            "mode": "local",
            "processId": 30834,
            "trace":"log"

The log file says:
2020-3-13, 07:00:16.821 UTC
[07:00:16.821 UTC] From client: initialize({"clientID":"vscode","clientName":"Visual Studio Code","adapterID":"go","pathFormat":"path","linesStartAt1":true,"columnsStartAt1":true,"supportsVariableType":true,"supportsVariablePaging":true,"supportsRunInTerminalRequest":true,"locale":"en-gb"})
[07:00:16.822 UTC] InitializeRequest
[07:00:16.822 UTC] To client: {"seq":0,"type":"response","request_seq":1,"command":"initialize","success":true,"body":{"supportsConfigurationDoneRequest":true,"supportsSetVariable":true}}
[07:00:16.822 UTC] InitializeResponse
[07:00:16.822 UTC] From client: attach({"name":"attach to process","type":"go","request":"attach","mode":"local","processId":30834,"trace":"log","packagePathToGoModPathMap":{"/home/ethereum/go/src/github.com/tendermint/tendermint/state":"/home/ethereum/go/src/github.com/tendermint/tendermint","/home/ethereum/go/src/github.com/tendermint/tendermint/node":"/home/ethereum/go/src/github.com/tendermint/tendermint","/home/ethereum/go/src/github.com/tendermint/tendermint/consensus":"/home/ethereum/go/src/github.com/tendermint/tendermint","/home/ethereum/go/src/github.com/tendermint/tendermint/.vscode":"/home/ethereum/go/src/github.com/tendermint/tendermint",".":"","/tmp":""},"env":{"GOPATH":"/home/ethereum/go","ELECTRON_RUN_AS_NODE":"1","USER":"ethereum","SSH_AGENT_PID":"2461","HOME":"/home/ethereum","QT4_IM_MODULE":"xim","GNOME_SHELL_SESSION_MODE":"ubuntu","GTK_MODULES":"gail:atk-bridge","DBUS_SESSION_BUS_ADDRESS":"unix:path=/run/user/1000/bus","PULSE_SCRIPT":"/etc/xrdp/pulse/default.pa","LOGNAME":"ethereum","GTK_IM_MODULE":"ibus","XDG_SESSION_ID":"c2","PATH":"/home/ethereum/.local/bin:/sbin:/bin:/usr/bin:/usr/local/bin:/snap/bin:/usr/local/go/bin:/usr/local/go/bin:/usr/local/go/bin:/usr/local/go/bin:/home/ethereum/go/bin:/home/ethereum/.local/bin","XRDP_SOCKET_PATH":"/var/run/xrdp/sockdir","XDG_RUNTIME_DIR":"/run/user/1000","DISPLAY":":10.0","LANG":"en_IN","XDG_CURRENT_DESKTOP":"Unity","XMODIFIERS":"@im=ibus","UID":"1000","SSH_AUTH_SOCK":"/run/user/1000/keyring/ssh","SHELL":"/bin/bash","QT_ACCESSIBILITY":"1","XRDP_SESSION":"1","GPG_AGENT_INFO":"/run/user/1000/gnupg/S.gpg-agent:0:1","QT_IM_MODULE":"xim","PWD":"/home/ethereum","XDG_DATA_DIRS":"/usr/share/gnome:/usr/share/ubuntu:/usr/local/share:/usr/share:/var/lib/snapd/desktop","XDG_CONFIG_DIRS":"/etc/xdg/xdg-ubuntu:/etc/xdg","CLUTTER_IM_MODULE":"xim","GNOME_DESKTOP_SESSION_ID":"this-is-deprecated","XDG_MENU_PREFIX":"gnome-","SESSION_MANAGER":"local/ethereum:@/tmp/.ICE-unix/2393,unix/ethereum:/tmp/.ICE-unix/2393","GIO_LAUNCHED_DESKTOP_FILE":"/usr/share/applications/code.desktop","GIO_LAUNCHED_DESKTOP_FILE_PID":"29849","GJS_DEBUG_OUTPUT":"stderr","GJS_DEBUG_TOPICS":"JS ERROR;JS LOG","NO_AT_BRIDGE":"1","CHROME_DESKTOP":"code-url-handler.desktop","VSCODE_NLS_CONFIG":"{\"locale\":\"en-gb\",\"availableLanguages\":{},\"_languagePackSupport\":true}","VSCODE_NODE_CACHED_DATA_DIR":"/home/ethereum/.config/Code/CachedData/c47d83b293181d9be64f27ff093689e8e7aed054","VSCODE_LOGS":"/home/ethereum/.config/Code/logs/20200311T163535","VSCODE_IPC_HOOK":"/run/user/1000/vscode-faaa7b3a-1.42.1-main.sock","VSCODE_PID":"29849","GL_DEBUG":"linters_output","GOPACKAGESPRINTGOLISTERRORS":"1","GOROOT":"/usr/local/go","LESSCLOSE":"/bin/lesspipe %s %s","LESSOPEN":"| /bin/lesspipe %s","LS_COLORS":"","SHLVL":"1","_":"/usr/share/code/code","AMD_ENTRYPOINT":"vs/workbench/services/extensions/node/extensionHostProcess","PIPE_LOGGING":"true","VERBOSE_LOGGING":"true","VSCODE_IPC_HOOK_EXTHOST":"/tmp/vscode-ipc-972dcaf6-f8a8-4cde-809e-d3edf9f6a5f2.sock","VSCODE_HANDLES_UNCAUGHT_ERRORS":"true","VSCODE_LOG_STACK":"false","APPLICATION_INSIGHTS_NO_DIAGNOSTIC_CHANNEL":"true","GOPROXY":"https://proxy.golang.org,direct"},"apiVersion":2,"dlvLoadConfig":{"followPointers":true,"maxVariableRecurse":1,"maxStringLen":64,"maxArrayValues":64,"maxStructFields":-1},"showGlobalVariables":true,"cwd":"/home/ethereum/go/src/github.com/tendermint/tendermint","dlvToolPath":"/home/ethereum/go/bin/dlv","currentFile":false,"__sessionId":"020b22be-94c2-4395-a521-18db82ebc783"})
[07:00:16.822 UTC] Current working directory: /home/ethereum/go/src/github.com/tendermint
[07:00:16.822 UTC] Running: /home/ethereum/go/bin/dlv attach 30834 --headless=true --listen=127.0.0.1:40048 --api-version=2 --wd=/home/ethereum/go/src/github.com/tendermint/tendermint
[07:00:16.829 UTC] To client: {"seq":0,"type":"event","event":"output","body":{"category":"stdout","output":"API server listening at: 127.0.0.1:40048\n"}}
[07:00:16.830 UTC] To client: {"seq":0,"type":"event","event":"output","body":{"category":"stderr","output":"Could not attach to pid 30834: this could be caused by a kernel security setting, try writing \"0\" to /proc/sys/kernel/yama/ptrace_scope\n"}}
[07:00:16.831 UTC] [Error] Process exiting with code: 1
[07:00:16.832 UTC] To client: {"seq":0,"type":"response","request_seq":2,"command":"attach","success":false,"message":"Failed to continue: Check the debug console for details.","body":{"error":{"id":3000,"format":"Failed to continue: Check the debug console for details.","showUser":true}}}
[07:00:16.832 UTC] Sending TerminatedEvent as delve is closed
[07:00:16.832 UTC] To client: {"seq":0,"type":"event","event":"terminated"}
[07:00:16.854 UTC] From client: disconnect({"restart":false})
[07:00:16.854 UTC] DisconnectRequest 
[07:00:16.854 UTC] HaltRequest 

Can someone help me out how to proceed further.

Thanks,
Anjana 

Brian Candler

unread,
Mar 13, 2020, 4:53:30 AM3/13/20
to golang-nuts
On Friday, 13 March 2020 07:45:57 UTC, Anjana Prabhakar wrote:
Can someone help me out how to proceed further.


Erm, why don't you try writing "0" to /proc/sys/kernel/yama/ptrace_scope ?

echo "0" >/proc/sys/kernel/yama/ptrace_scope

Reply all
Reply to author
Forward
0 new messages