Skip to content
This repository has been archived by the owner on Aug 2, 2023. It is now read-only.

Debugging fails with timeout when using conda run #1944

Closed
karrtikr opened this issue Nov 22, 2019 · 2 comments
Closed

Debugging fails with timeout when using conda run #1944

karrtikr opened this issue Nov 22, 2019 · 2 comments
Assignees
Labels

Comments

@karrtikr
Copy link

@karthiknadig

Environment data

  • PTVSD version: 5.0.0a7
  • OS: Windows_NT x64 10.0.18363
  • Python version (& distribution if applicable, e.g. Anaconda): Python 3.7.4 , Anaconda
  • Using VS Code or Visual Studio: Version: 1.41.0-insider (user setup)

Steps to reproduce:

  1. Add the following config in launch.json.
{
    "name": "Python: Current File",
    "type": "python",
    "request": "launch",
    "program": "${file}",
    "console": "integratedTerminal",
    "python": [
        "conda",
        "run",
        "-n",
        "base",
        "python"
    ],
    "logToFile": true
}
  1. Debug the python extension. Make sure you're in experiments DebugAdapterFactory - experiment and PtvsdWheels37 - experiment. Remove all references in the resolver to "pythonPath" as it's deprecated.
  2. Select conda as interpreter.
  3. Start debugging.

Expected behavior

Debugging works. And the command should begin with conda run -n base python ....

Actual behavior

The command:
image

Debugging fails:
image

Log files

debugger.vscode_dbc3a284-d158-4e8b-9cfc-ddd709011d6b.log
ptvsd.adapter-17808.log
ptvsd.launcher-18848.log
ptvsd.server-17816.log

@int19h
Copy link
Contributor

int19h commented Nov 22, 2019

I believe that this is fundamentally the same problem as #1930, the fix for which has only just went in. Can you try it with ptvsd v5.0.0a8, and see if that fixes it?

@int19h
Copy link
Contributor

int19h commented Nov 22, 2019

Actually, looking at the logs, I don't think even that would help. Not even the parent PID matches what we spawned:

I+00001.203: /handling #2 request "launch" from IDE[1]/
             Waiting for connection from debug server with PID=35692...

D+00003.047: Server[?] --> {
                     ...
                     "process": {
                         "pid": 17816,
                         "ppid": 27720,
                         "executable": "C:\\Users\\karraj\\AppData\\Local\\Continuum\\anaconda3\\python.exe",
                         "bitness": 64
                     }
                 }
             }

Looking at the source code for conda run, it's because it generates a massive shell script, and then uses the shell to run that. So the chain is ptvsd.launcher -> conda -> cmd.exe -> python.exe, where the PID that the launcher has from spawning the process is that of conda, but neither the PID nor the parent PID it gets from python.exe matches that.

So it's the same fundamental problem, but the fix for #1930 won't work. It seems that we'll have to remove PID validation entirely, and just assume that the first connection that comes in is the launched process, regardless of which PID it reports. :/

@int19h int19h self-assigned this Nov 22, 2019
@int19h int19h added the Bug label Nov 22, 2019
int19h added a commit to int19h/ptvsd that referenced this issue Nov 22, 2019
Do not validate PID of the debuggee when debug server connects while handling "launch".

Restrict "launch" to the first session with no server connections.
@int19h int19h closed this as completed in ad36606 Nov 22, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants