Type: Debugger
Input information below
Please review existing issues and our documentation at https://github.com/Microsoft/vscode-cpptools/tree/master/Documentation prior to filing an issue.
Describe the bug
Linux version 5.1.5-arch1-2-ARCH (builduser@heftig-23132) (gcc version 8.3.0 (GCC)) #1 SMP PREEMPT Mon May 27 03:37:39 UTC 2019
1.34.0
a622c65b2c713c890fcf4fbf07cf34049d5fe758
x64
[email protected]
I wanted to debug a process that requires superuser access, but it fails trying to execute a shell script in the integrated terminal:
$ env sh /tmp/Microsoft-MIEngine-Cmd-lz6gxbg1.9wn
"Superuser
It hangs there waiting for user input.
This is the content of /tmp/Microsoft-MIEngine-Cmd-lz6gxbg1.9wn:
echo $$ > /tmp/Microsoft-MIEngine-Pid-65s8vwo4.61n ; cd /home/lukasz/.vscode/extensions/ms-vscode.cpptools-0.23.1/bin ; DbgTerm=`tty` ; set -o monitor ; trap 'rm /tmp/Microsoft-MIEngine-In-192rk68v.d01 /tmp/Microsoft-MIEngine-Out-9tf7izkn.281 /tmp/Microsoft-MIEngine-Pid-65s8vwo4.61n /tmp/Microsoft-MIEngine-Cmd-lz6gxbg1.9wn' EXIT ; read -n 1 -p \"Superuser access is required to attach to a process. Attaching as superuser can potentially harm your computer. Do you want to continue? [y/N]\" yn; if [[ ! $yn =~ ^[Yy]$ ]] ; then exit 0; fi; /usr/bin/pkexec /usr/bin/gdb --interpreter=mi --tty=$DbgTerm < /tmp/Microsoft-MIEngine-In-192rk68v.d01 > /tmp/Microsoft-MIEngine-Out-9tf7izkn.281 & clear; pid=$! ; echo $pid > /tmp/Microsoft-MIEngine-Pid-65s8vwo4.61n ; wait $pid;
It seems that it incorrectly escapes quotes around the message.
To Reproduce
Please include a code sample and launch.json configuration.
{
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) Attach",
"type": "cppdbg",
"request": "attach",
"program": "/home/lukasz/.vscode/extensions/ms-vscode.cpptools-0.23.1/bin/Microsoft.VSCode.CPP.Extension.linux",
"processId": "${command:pickProcess}",
"MIMode": "gdb"
}
]
}
I get
$ env sh /tmp/Microsoft-MIEngine-Cmd-wn924gm2.kaq
"Superuser
until I press a key, then the terminal shows
$ env sh /tmp/Microsoft-MIEngine-Cmd-wn924gm2.kaq
"Superuser
/tmp/Microsoft-MIEngine-Cmd-wn924gm2.kaq: line 1: read: `process.': not a valid identifier
I am using attach with an explicit process id, no selection dialog.
Same issue? Any workaround aside from running sudo code .?
_Originally posted by @davidsgrogan in https://github.com/microsoft/vscode-cpptools/issues/3042#issuecomment-480096784_
I have the exact same problem as you @davidsgrogan
If you find a solution, please let me know.
_Originally posted by @Thalley in https://github.com/microsoft/vscode-cpptools/issues/3042#issuecomment-491822687_
I have the same issue. If I go into the _/tmp/Microsoft-MIEngine-Cmd-wn924gm2.kaq_ and swap the escaped double quotes here _...\"Superuser..._ and here _...Do you want to continue? [y/N]\"..._ with single quotes. I can call the command "env sh /tmp/Microsoft-MIEngine-Cmd-wn924gm2.kaq " succesfully. I think the temprorary script _Microsoft-MIEngine-Cmd-wn924gm2.kaq_ might be created with an error causing this bug. I couldn't find where this script is created so I couldn't attempt to fix it but maybe this info is helpful to you.
_Originally posted by @ozbeka in https://github.com/microsoft/vscode-cpptools/issues/3042#issuecomment-500541501_
I found the place where (I believe) this script is generated and opened a pull-request to hopefully fix this.
Thanks to @ChristianJacobsen, this fix should be in our next release.
I still have this issue in
Version: 1.39.2
Commit: 6ab598523be7a800d7f3eb4d92d7ab9a66069390
Date: 2019-10-15T15:33:40.634Z
Electron: 4.2.10
Chrome: 69.0.3497.128
Node.js: 10.11.0
V8: 6.9.427.31-electron.0
OS: Linux x64 4.15.0-65-generic
I have to start vscode with sudo to attach gdb.