VSCode version: 1.37.1
System: Kubuntu 19.04
Working extension: 0.24.1
NOT working extension: 0.25
Description: after upgrade extension to 0.25 I cannot attach GDB to existing process. After select process to debug I should see message dialog about 'sudo' password, nedded by GDB
launch.json
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) Attach",
"type": "cppdbg",
"request": "attach",
"program": "${workspaceFolder}/build/test.bin",
"processId": "${command:pickProcess}",
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
},
]
}
simple code to test (test.cpp):
#include "stdio.h"
#include <iostream> // std::cout
int main ()
{
int a, b;
std::string xxx;
do
{
a = 1;
b= 2;
a = b;
std::cin >> xxx;
std::cout << std::endl << xxx << std::endl;
b = 1;
} while (1);
return 1;
}
Steps to reproduce:
in 0.24.1 just call (KDE dialog window):
/usr/lib/policykit-1/polkit-agent-helper-1 username
and asks for password.
in 0.25 I got in the terminal:
[1] + Done(127) "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} 0<"/tmp/Microsoft-MIEngine-In-jvutpqrc.17z" 1>"/tmp/Microsoft-MIEngine-Out-kf1esh3m.x2e"
This probably has to do with a fix for a different case that @ChristianJacobsen
submitted. https://github.com/microsoft/MIEngine/commit/597e41ffab1d20d4ed6e602fe080154cee82a9d2
I don't know why fixing it for his case would cause this case to fail.
@WardenGnaw Do you have any ideas?
I'd rather just use the debugger in Launch mode than cause a regression issue for you guys. If possible just roll back my 'fix' :)
I think it might be a bug with VSCode for me, because now the script doesn't freak out because of the double-escaped quotes, but still doesn't ask for a password.
Seems there's still an issue with the placement of the double quotes. I see that there's an 'extra' one after the call to /usr/bin/pkexec /usr/bin/gdb.
@ChristianJacobsen Where do you see the extra one? With all the distributions out there its hard to determine which ones work and which ones don't. Can you verify if a ' will work in your instance? If so, that might be the "correct" fix.
Given:
[1] + Done(127) "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} 0<"/tmp/Microsoft-MIEngine-In-jvutpqrc.17z" 1>"/tmp/Microsoft-MIEngine-Out-kf1esh3m.x2e"
I'm unsure if character 34 is just how the shell outputs the command, but I know that character 272 shouldn't be there. If you take the string and paste in into any IDE with syntax highlighting for shell scripts you'll see that it inverts the quoting for the redirections of input/output. I don't think ' vs " is the issue here.
@ChristianJacobsen I'm trying to see if this fix will solve both the problems: https://github.com/microsoft/MIEngine/pull/927
It's replacing the original \\\" with ' as there should be no expansion within the string that we're prompting with.
Sounds good @pieandcakes! Sorry for the inconvenience my 'fix' has caused! :)
Fixed with 0.25.1.
Tested on two different environments: works OK. Thanks for the help.
@ChristianJacobsen can you see if 0.25.1 also works for your scenario? if not, i can continue to investigate.
Hi @pieandcakes.
Now it's gotten one step further at least. I get the full prompt on whether I want to attach as superuser or not, but when I type 'Y' and hit enter it doesn't wait at the password prompt.
==== AUTHENTICATING FOR org.freedesktop.policykit.exec ====
Authentication is needed to run `/sbin/gdb' as the super user
Authenticating as: user
Password: %
I've tried with both bash and zsh, neither of them waits.
Any configuration options you can think of, for pkexec or other commands, that would fix this?
@MaciejRutecki, did you have to do any configuration in Kubuntu?
@ChristianJacobsen default installation. I see that cpptools uses polkit in KDE/Plasma (package: 'polkit-kde-agent-1') + 'policykit-1' package.
Hi, I've hit this issue and after closing vscode and starting seems to be working fine.
Though a colleague of mine still has the issue with v 0.25.1, what I've noticed different is that the "conda activate
(base)$ sh /tmp/Microsoft-MIEngine-Cmd-t824anlw.u8w
Superuser access is required to attach to a process. Attaching as superuser can potentially harm your computer. Do you want to continue? [y/N]source /home/user1/miniconda3/bin/activate
(base)$ conda activate conda_environment
on my case the order is inverse, conda activates first then the gdb debug script is executed, and it is working.
So this issue might just be related with command/extension initialization priority and due to the requested input in the terminal.
Previous script did not had the terminal prompt, just the sudo window would show up to input the password...
Previous script did not had the terminal prompt, just the sudo window would show up to input the password...
Confirm: ask for run as root/sudo firrst, then show dialog box with input for the password. In 0.24 just ask for password only.
We try and detect that pkexec is there, if not we fall back to sudo. The original problem was around the quoting of the parameter to read so I moved the message to a regular echo instead and am calling read. If this still isn't working, please let me know how to configure a scratch machine to try out.
Hi, I've hit this issue and after closing vscode and starting seems to be working fine.
Though a colleague of mine still has the issue with v 0.25.1, what I've noticed different is that the "conda activate " command in his case is issued after the gdb debug script, and it seems that is interfering with the root access prompt.
(base)$ sh /tmp/Microsoft-MIEngine-Cmd-t824anlw.u8w Superuser access is required to attach to a process. Attaching as superuser can potentially harm your computer. Do you want to continue? [y/N]source /home/user1/miniconda3/bin/activate (base)$ conda activate conda_environmenton my case the order is inverse, conda activates first then the gdb debug script is executed, and it is working.
So this issue might just be related with command/extension initialization priority and due to the requested input in the terminal.
Previous script did not had the terminal prompt, just the sudo window would show up to input the password...
I have the same problem still.
Most helpful comment
Fixed with 0.25.1.