profile
viewpoint

Ask questionsDebugging with new_ptvsd is crashing because of TypeError: Struct()

<!-- Please search existing issues to avoid creating duplicates. -->

Environment data

  • VS Code version: 1.40.1
  • Extension version (available under the Extensions sidebar): 2019.11.49689
  • OS and version: RH7.6
  • Python version (& distribution if applicable, e.g. Anaconda): 2.7.5

Expected behaviour

Debugger works fine

Actual behaviour

It crashes.. stack:

[root@rh01 ~]# /usr/bin/python /root/.vscode-server/extensions/ms-python.python-2019.11.49689/pythonFiles/lib/python/new_ptvsd/no_wheels/ptvsd/launcher /root/helloworld/helloworld.py 
E+00000.020: /handling microsoft/vscode-python#1 request "launch" from Adapter-1/
             Handler 'launch_request' (file u'/root/.vscode-server/extensions/ms-python.python-2019.11.49689/pythonFiles/lib/python/new_ptvsd/no_wheels/ptvsd/launcher/../../ptvsd/launcher/adapter.py', line 35)
             couldn't handle microsoft/vscode-python#1 request "launch" from Adapter-1:
             
             Traceback (most recent call last):
               File "/root/.vscode-server/extensions/ms-python.python-2019.11.49689/pythonFiles/lib/python/new_ptvsd/no_wheels/ptvsd/launcher/../../ptvsd/common/messaging.py", line 763, in _handle
                 result = handler(self)
               File "/root/.vscode-server/extensions/ms-python.python-2019.11.49689/pythonFiles/lib/python/new_ptvsd/no_wheels/ptvsd/launcher/../../ptvsd/launcher/adapter.py", line 147, in launch_request
                 debuggee.spawn(process_name, cmdline, cwd, env, redirect_output)
               File "/root/.vscode-server/extensions/ms-python.python-2019.11.49689/pythonFiles/lib/python/new_ptvsd/no_wheels/ptvsd/launcher/../../ptvsd/launcher/debuggee.py", line 76, in spawn
                 "pointerSize": struct.calcsize("P") * 8,
             TypeError: Struct() argument 1 must be string, not unicode
             
             Stack where logged:
               File "/usr/lib64/python2.7/threading.py", line 785, in __bootstrap
                 self.__bootstrap_inner()
               File "/usr/lib64/python2.7/threading.py", line 812, in __bootstrap_inner
                 self.run()
               File "/usr/lib64/python2.7/threading.py", line 765, in run
                 self.__target(*self.__args, **self.__kwargs)
               File "/root/.vscode-server/extensions/ms-python.python-2019.11.49689/pythonFiles/lib/python/new_ptvsd/no_wheels/ptvsd/launcher/../../ptvsd/common/messaging.py", line 1520, in _run_handlers
                 handler()
               File "/root/.vscode-server/extensions/ms-python.python-2019.11.49689/pythonFiles/lib/python/new_ptvsd/no_wheels/ptvsd/launcher/../../ptvsd/common/messaging.py", line 809, in _handle
                 self.describe(),

Steps to reproduce:

  1. Just F5 to debug.
  2. Getting this error
  3. also getting an error to check launch,json - Launcher[1] disconnected unexpectedly
  4. launcher is somehow still listening in the background

ps x | grep ptvsd

 9815 pts/3    S      0:00 /usr/bin/python /root/.vscode-server/extensions/ms-python.python-2019.11.49689/pythonFiles/lib/python/new_ptvsd/no_wheels/ptvsd --client --host 127.0.0.1 --port 41995 /root/helloworld/helloworld.py
 9869 pts/3    S      0:00 /usr/bin/python /root/.vscode-server/extensions/ms-python.python-2019.11.49689/pythonFiles/lib/python/new_ptvsd/no_wheels/ptvsd --client --host 127.0.0.1 --port 39855 /root/helloworld/helloworld.py

  1. it is verified to be working with the previous release of python extension which does not make use of ptvsd_new

launch.json contents:

{
    // 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": "Python: Current File",
            "type": "python",
            "request": "launch",
            "program": "${file}",
            "console": "integratedTerminal"
        }
    ]
}
microsoft/ptvsd

Answer questions fabioz

@duduz if you just change locally to use bytes in calcsize, do you have any other issues?

i.e.: use struct.calcsize(b"P") in /root/.vscode-server/extensions/ms-python.python-2019.11.49689/pythonFiles/lib/python/new_ptvsd/no_wheels/ptvsd/launcher/../../ptvsd/launcher/debuggee.py", line 76, in spawn

useful!
source:https://uonfu.com/
answerer
Fabio Zadrozny fabioz Python enthusiast. Maintainer of PyDev, PyDev.Debugger, LiClipse, LiClipseText, PyVmMonitor and mu-repo
Github User Rank List