Skip to content

Remote attach is very very buggy. Debug adapter crashes all the time #93

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
DonJayamanne opened this issue Nov 13, 2017 · 12 comments
Closed
Labels
area-debugging bug Issue identified by VS Code Team member as probable bug

Comments

@DonJayamanne
Copy link

From @nojvek on March 14, 2017 0:8

Environment data

VS Code version: Version 1.10.2 (1.10.2)
Python Extension version: 0.5.9
Python Version: 2.7
OS and version: Mac OS Sierra

Expected behavior

Remote attach works like Chrome-Dev tools

Actual behavior

Python remote debugger connects with orange but crashes later

Steps to reproduce:

  • Run attach scenario

Settings

Your launch.json (if dealing with debugger issues):

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Attach (Remote Debug)",
            "type": "python",
            "request": "attach",
            "localRoot": "${workspaceRoot}",
            "remoteRoot": "/home/noj/xyz",
            "port": 3333,
            "secret": "boo",
            "host": "localhost"
        }
    ]
}

Your settings.json:

Logs

Output from Python output panel
----------Generating Tags----------
ctags --options=/Users/nojvek/.vscode/extensions/donjayamanne.python-0.5.9/resources/ctagOptions --languages=Python --exclude=/site-packages/ -o /Users/nojvek/mp/analytics/.vscode/tags .
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ctags: illegal option -- -
usage: ctags [-BFadtuwvx] [-f tagsfile] file ...

Output from Console window (Help->Developer Tools menu)

workbench.main.js:142 TypeError: Cannot read property 'Threads' of undefined
    at PythonDebugger.threadsRequest (/Users/nojvek/.vscode/extensions/donjayamanne.python-0.6.0/out/client/debugger/Main.js:339:27)
    at PythonDebugger.DebugSession.dispatchRequest (/Users/nojvek/.vscode/extensions/donjayamanne.python-0.6.0/node_modules/vscode-debugadapter/lib/debugSession.js:427:22)
    at PythonDebugger.ProtocolServer._handleData (/Users/nojvek/.vscode/extensions/donjayamanne.python-0.6.0/node_modules/vscode-debugadapter/lib/protocol.js:104:38)
    at Socket.<anonymous> (/Users/nojvek/.vscode/extensions/donjayamanne.python-0.6.0/node_modules/vscode-debugadapter/lib/protocol.js:24:60)
    at emitOne (events.js:96:13)
    at Socket.emit (events.js:188:7)
    at readableAddChunk (_stream_readable.js:176:18)
    at Socket.Readable.push (_stream_readable.js:134:10)
    at Pipe.onread (net.js:543:20): Error: TypeError: Cannot read property 'Threads' of undefined
    at PythonDebugger.threadsRequest (/Users/nojvek/.vscode/extensions/donjayamanne.python-0.6.0/out/client/debugger/Main.js:339:27)
    at PythonDebugger.DebugSession.dispatchRequest (/Users/nojvek/.vscode/extensions/donjayamanne.python-0.6.0/node_modules/vscode-debugadapter/lib/debugSession.js:427:22)
    at PythonDebugger.ProtocolServer._handleData (/Users/nojvek/.vscode/extensions/donjayamanne.python-0.6.0/node_modules/vscode-debugadapter/lib/protocol.js:104:38)
    at Socket.<anonymous> (/Users/nojvek/.vscode/extensions/donjayamanne.python-0.6.0/node_modules/vscode-debugadapter/lib/protocol.js:24:60)
    at emitOne (events.js:96:13)
    at Socket.emit (events.js:188:7)
    at readableAddChunk (_stream_readable.js:176:18)
    at Socket.Readable.push (_stream_readable.js:134:10)
    at Pipe.onread (net.js:543:20)
    at file:////Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/electron-browser/workbench.main.js:95:13980
    at Object.v [as _notify] (file:////Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/electron-browser/workbench.main.js:32:11161)
    at Object.enter (file:////Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/electron-browser/workbench.main.js:32:14666)
    at _run (file:////Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/electron-browser/workbench.main.js:32:15987)
    at _error (file:////Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/electron-browser/workbench.main.js:32:15504)
    at file:////Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/electron-browser/workbench.main.js:88:1241
    at g.e.dispatch (file:////Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/electron-browser/workbench.main.js:88:2592)
    at g.e.handleData (file:////Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/electron-browser/workbench.main.js:88:2100)
    at Socket.<anonymous> (file:////Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/electron-browser/workbench.main.js:88:1101)
    at emitOne (events.js:96:13)

Copied from original issue: DonJayamanne/pythonVSCode#819

@DonJayamanne
Copy link
Author

From @nojvek on March 14, 2017 0:17

I may know a thing or two about vscode debug adapters. I can definitely help get this issue fixed if someone is able to help me with the python side of things.

@DonJayamanne
Copy link
Author

Have you tried this with a simple console application and attaching to a python application running in your locality machine first.

@DonJayamanne
Copy link
Author

From @nojvek on March 14, 2017 16:55

I'll give that a shot. It seems threading might have to do something to do with it.

TypeError: Cannot read property 'Threads' of undefined. I was digging into the ptvsd code yest, is there a way for me to enable debugging on the tcp port that is exposed by the python app?

I need to first isolate that this is a client side issue on the debug adapter or an issue with debug server run by python. Is there any protocol documentation?

@DonJayamanne
Copy link
Author

Unfortunately, the answer is no to all of them.

@DonJayamanne
Copy link
Author

From @woutor on July 28, 2017 22:1

For those using Django, I also get the above exception, unless I provide the --nothreading argument to django manage.py.

python manage.py runserver 0.0.0.0:8000 --noreload --nothreading does the job

@DonJayamanne
Copy link
Author

@nojvek please try the following suggestions:

  • If debugging Django, then ensure --notreading options is used
  • Ensure the PTVSD package is of version 3.0.0 (anything higher will not work)

@DonJayamanne
Copy link
Author

From @nojvek on July 29, 2017 5:55

Will give it a shot. Thanks

On Fri, Jul 28, 2017 at 9:33 PM Don Jayamanne [email protected]
wrote:

@nojvek https://github.com/nojvek please try the following suggestions:

  • If debugging Django, then ensure --notreading options is used
  • Ensure the PTVSD package is of version 3.0.0 (anything higher will
    not work)


You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub
https://github.com/DonJayamanne/pythonVSCode/issues/819#issuecomment-318803363,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AA-JVHQVnqnbXFQ2jThqUhmtGkKsHoghks5sSrYRgaJpZM4Mb-MZ
.

@DonJayamanne
Copy link
Author

From @jarshwah on August 2, 2017 13:8

I looked into getting this working a couple of months back but abandoned because of the bugginess. It was easier for me to just use ipdb which is unfortunate, because debugging is just about the only thing I prefer pycharm for.

Anyhow, what I found was that the --noreload and --nothreading options were necessary. I also added the import of ptvsd and the ptvsd.wait_for_attach() call into the manage.py file which seemed to work the most reliably.

Happy to assist where I can. Would anyone from the python tools for visual studio team be able to help here? Surely they've run into similar issues during the development of ptvsd.

@DonJayamanne
Copy link
Author

From @caspar-1 on August 10, 2017 13:14

might be usefull if the Remote-Debuging wiki page clarified that PTVSD version must be 3.0.0

@brettcannon brettcannon added awaiting 2-PR area-debugging bug Issue identified by VS Code Team member as probable bug labels Nov 14, 2017
@alanjds
Copy link

alanjds commented Nov 27, 2017

It worked after changed the version to 3.0.0

@alanjds
Copy link

alanjds commented Nov 27, 2017

Please replace the referred Wiki page code with this one:

[Remote Debugging](https://code.visualstudio.com/docs/python/debugging#_remote-debugging)

### Note:

As said [here](https://github.com/Microsoft/vscode-python/issues/93#issuecomment-344084499), install `ptvsd==3.0.0`, as this version is known to work.

```bash
pip install ptvsd==3.0.0

@DonJayamanne
Copy link
Author

@alanjds Thanks, created an issue for that #299

@lock lock bot locked as resolved and limited conversation to collaborators Jul 11, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-debugging bug Issue identified by VS Code Team member as probable bug
Projects
None yet
Development

No branches or pull requests

3 participants