Skip to content

Remote Debugger crash: TypeError: Cannot read property 'Threads' of undefined #126

Closed

Description

From Alexander Bantyev (@balsoft) on June 3, 2017 14:45

Environment data

VS Code version: 1.12.2
Python Extension version: 0.6.4
Python Version: 3.6
OS and version: Arch Linux x86_64, Latest (All packages up-to-date)

Actual behavior

Remote debugger crashes when I try to attach it to remote app.
Message from devConsole:

Expected behavior

Remote debugger attaches

Steps to reproduce:

  • Create a simple script on one Linux device (Ubuntu Linux 16.04 x86_64, Python3, ptvsd installed)
import ptvsd
ptvsd.enable_attach("secret", address=('0.0.0.0', 4000))

# Wait for debugger
ptvsd.wait_for_attach()
  • Run it
  • Switch to another Linux device (Arch Linux x86_64, Latest, ptvsd installed, VS Code Installed)
  • Run VS Code, open the same script locally, debug with "Attach (Remote Debug)"
  • Debugger crashes

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/balsoft/Documents/",
            "port": 4000,
            "secret": "secret",
            "host": "192.168.1.67"
        }
    ]
}

Your settings.json:

{
    "window.zoomLevel": 0,
    "files.autoSave": "onFocusChange",
    "debug.inlineValues": true,
    "debug.hideActionBar": false,
    "workbench.colorTheme": "One Dark Pro",
    "auto-close-tag.enableAutoCloseTag": false,
    "auto-close-tag.SublimeText3Mode": true
}

Logs

Output from Python output panel

##########Linting Output - pylint##########
************* Module test
1,0,convention,C0111:Missing module docstring

---------------------------------------------------------------------
Your code has been rated at 6.67/10 (previous run: -13.33/10, +20.00)


No config file found, using default configuration

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

TypeError: Cannot read property 'Threads' of undefined
    at PythonDebugger.threadsRequest (/home/balsoft/.vscode/extensions/donjayamanne.python-0.6.4/out/client/debugger/Main.js:340:27)
    at PythonDebugger.DebugSession.dispatchRequest (/home/balsoft/.vscode/extensions/donjayamanne.python-0.6.4/node_modules/vscode-debugadapter/lib/debugSession.js:427:22)
    at PythonDebugger.ProtocolServer._handleData (/home/balsoft/.vscode/extensions/donjayamanne.python-0.6.4/node_modules/vscode-debugadapter/lib/protocol.js:104:38)
    at Socket.<anonymous> (/home/balsoft/.vscode/extensions/donjayamanne.python-0.6.4/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:551:20): Error: TypeError: Cannot read property 'Threads' of undefined
    at PythonDebugger.threadsRequest (/home/balsoft/.vscode/extensions/donjayamanne.python-0.6.4/out/client/debugger/Main.js:340:27)
    at PythonDebugger.DebugSession.dispatchRequest (/home/balsoft/.vscode/extensions/donjayamanne.python-0.6.4/node_modules/vscode-debugadapter/lib/debugSession.js:427:22)
    at PythonDebugger.ProtocolServer._handleData (/home/balsoft/.vscode/extensions/donjayamanne.python-0.6.4/node_modules/vscode-debugadapter/lib/protocol.js:104:38)
    at Socket.<anonymous> (/home/balsoft/.vscode/extensions/donjayamanne.python-0.6.4/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:551:20)
    at file:////opt/visual-studio-code/resources/app/out/vs/workbench/electron-browser/workbench.main.js:28:2217016
    at Object.v [as _notify] (file:////opt/visual-studio-code/resources/app/out/vs/workbench/electron-browser/workbench.main.js:28:68877)
    at Object.enter (file:////opt/visual-studio-code/resources/app/out/vs/workbench/electron-browser/workbench.main.js:28:72378)
    at n.Class.derive._oncancel._run (file:////opt/visual-studio-code/resources/app/out/vs/workbench/electron-browser/workbench.main.js:28:73699)
    at n.Class.derive._oncancel._error (file:////opt/visual-studio-code/resources/app/out/vs/workbench/electron-browser/workbench.main.js:28:73216)
    at file:////opt/visual-studio-code/resources/app/out/vs/workbench/electron-browser/workbench.main.js:28:1952866
    at g.e.dispatch (file:////opt/visual-studio-code/resources/app/out/vs/workbench/electron-browser/workbench.main.js:28:1954217)
    at g.e.handleData (file:////opt/visual-studio-code/resources/app/out/vs/workbench/electron-browser/workbench.main.js:28:1953725)
    at Socket.<anonymous> (file:////opt/visual-studio-code/resources/app/out/vs/workbench/electron-browser/workbench.main.js:28:1952726)
    at emitOne (events.js:96:13)

Note

If I don't run my script on remote device and attempt to start remote debugger it fails as expected (ECONNREFUSED), so it's almost definetly a bug in debugger.

Copied from original issue: DonJayamanne/pythonVSCode#999

Activity

  1. DonJayamanne commented on Nov 13, 2017

    @DonJayamanne
    Author

    Please try using ptvsd 3.0.0 (temporary solution)

  2. DonJayamanne commented on Nov 13, 2017

    @DonJayamanne
    Author

    From Derrick (@d4tech) on June 21, 2017 8:31

    The issue still persists even after using ptvsd 3.0.0.

  3. DonJayamanne commented on Nov 13, 2017

    @DonJayamanne
    Author

    From Andrew Holway (@mooperd) on July 18, 2017 8:18

    +1

  4. DonJayamanne commented on Nov 13, 2017

    @DonJayamanne
    Author

    From Wouter (@woutor) on July 28, 2017 22:3

    For those using Django, try to run with the --nothreading argument:

    python manage.py runserver 0.0.0.0:8000 --noreload --nothreading

  5. DonJayamanne commented on Nov 13, 2017

    @DonJayamanne
    Author

    From Moeen Zamani (@moeenz) on August 11, 2017 18:17

    Apparently there's an issue with port numbers. I changed it from 3xxx to 9xxx and everything's working fine.

  6. DonJayamanne commented on Nov 13, 2017

    @DonJayamanne
    Author

    Alexander Bantyev (@balsoft) are you still experiencing this issue.

  7. DonJayamanne commented on Nov 13, 2017

    @DonJayamanne
    Author

    From Waleed Abdulla (@waleedka) on October 16, 2017 0:51

    I'm experiencing this issue as well while trying to debug a python script inside a Docker container. I tried using ptvsd 3.0.0 as recommended in one of the comments above but that didn't make a difference.

    VS Code version: 1.17.1
    Python Extension version: 0.7.0
    Python Version: 3.5.2
    OS and version: OSX 10.11.6

    launch.json

            {
                "name": "Attach (Remote Debug)",
                "type": "python",
                "request": "attach",
                "localRoot": "${workspaceRoot}",
                "remoteRoot": "${workspaceRoot}",
                "port": 3000,
                "secret": "some secret",
                "host": "localhost"
            }
    

    Developer Tools Log:

    TypeError: Cannot read property 'Threads' of undefined
        at PythonDebugger.threadsRequest (/Users/waleed/.vscode/extensions/donjayamanne.python-0.7.0/out/client/debugger/Main.js:364:27)
        at PythonDebugger.DebugSession.dispatchRequest (/Users/waleed/.vscode/extensions/donjayamanne.python-0.7.0/node_modules/vscode-debugadapter/lib/debugSession.js:427:22)
        at PythonDebugger.ProtocolServer._handleData (/Users/waleed/.vscode/extensions/donjayamanne.python-0.7.0/node_modules/vscode-debugadapter/lib/protocol.js:104:38)
        at Socket.<anonymous> (/Users/waleed/.vscode/extensions/donjayamanne.python-0.7.0/node_modules/vscode-debugadapter/lib/protocol.js:24:60)
        at emitOne (events.js:96:13)
        at Socket.emit (events.js:191:7)
        at readableAddChunk (_stream_readable.js:178:18)
        at Socket.Readable.push (_stream_readable.js:136:10)
        at Pipe.onread (net.js:560:20): Error: TypeError: Cannot read property 'Threads' of undefined
        at PythonDebugger.threadsRequest (/Users/waleed/.vscode/extensions/donjayamanne.python-0.7.0/out/client/debugger/Main.js:364:27)
        at PythonDebugger.DebugSession.dispatchRequest (/Users/waleed/.vscode/extensions/donjayamanne.python-0.7.0/node_modules/vscode-debugadapter/lib/debugSession.js:427:22)
        at PythonDebugger.ProtocolServer._handleData (/Users/waleed/.vscode/extensions/donjayamanne.python-0.7.0/node_modules/vscode-debugadapter/lib/protocol.js:104:38)
        at Socket.<anonymous> (/Users/waleed/.vscode/extensions/donjayamanne.python-0.7.0/node_modules/vscode-debugadapter/lib/protocol.js:24:60)
        at emitOne (events.js:96:13)
        at Socket.emit (events.js:191:7)
        at readableAddChunk (_stream_readable.js:178:18)
        at Socket.Readable.push (_stream_readable.js:136:10)
        at Pipe.onread (net.js:560:20)
        at file:///Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/workbench.main.js:28:2241540
        at Object.v [as _notify] (file:///Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/workbench.main.js:28:54141)
        at Object.enter (file:///Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/workbench.main.js:28:57633)
        at n.Class.derive._oncancel._run (file:///Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/workbench.main.js:28:58954)
        at n.Class.derive._oncancel._error (file:///Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/workbench.main.js:28:58471)
        at file:///Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/workbench.main.js:28:2055793
        at _.e.dispatch (file:///Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/workbench.main.js:28:2057144)
        at _.e.handleData (file:///Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/workbench.main.js:28:2056652)
        at Socket.<anonymous> (file:///Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/workbench.main.js:28:2055653)
        at emitOne (events.js:96:13)
    
  8. DonJayamanne commented on Nov 16, 2017

    @DonJayamanne
    Author

    Could be related to #157 (even though that's local debugging)

  9. DonJayamanne commented on Jan 2, 2018

    @DonJayamanne
    Author

    Alexander Bantyev (@balsoft) Waleed Abdulla (@waleedka) Are you still experiencing this issue with the latest version of the extension.
    We've fixed a number of bugs in the debugger since then.

    Please could you check and get back to me.
    I've tested this at my end and it works as expected.

  10. MikhailArkhipov commented on Feb 12, 2018

    @MikhailArkhipov

    It's been a while without more info, closing. Feel free to reactivate if this is still a problem. Thanks.

  11. locked as resolved and limited conversation to collaborators on Jul 12, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-debuggingbugIssue identified by VS Code Team member as probable buginfo-neededIssue requires more information from poster

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions