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

ptvsd hangs until typing in the Debug Console then fails with thread_id as Nonetype #1326

Closed
JoshuaC3 opened this issue Apr 9, 2019 · 7 comments
Assignees

Comments

@JoshuaC3
Copy link

JoshuaC3 commented Apr 9, 2019

Environment data

  • PTVSD version: 2019.3.6558
  • OS and version: Ubuntu 16.04
  • Python version (& distribution if applicable, e.g. Anaconda): Anaconda Python 3.6.5
  • Using VS Code or Visual Studio: VSCode

Actual behavior

The debugger hangs until you click in the Debug Console text entry box and start typing. At this point, the following error message appears:

Traceback (most recent call last):
:undefined
  File "/home/josh/.vscode/extensions/ms-python.python-2019.3.6558/pythonFiles/lib/python/ptvsd/_vendored/pydevd/_pydevd_bundle/pydevd_comm.py", line 284, in _on_run
:undefined
    self.process_net_command_json(self.global_debugger_holder.global_dbg, json_contents)
  File "/home/josh/.vscode/extensions/ms-python.python-2019.3.6558/pythonFiles/lib/python/ptvsd/_vendored/pydevd/_pydevd_bundle/pydevd_process_net_command_json.py", line 137, in process_net_command_json
:undefined
    cmd = on_request(py_db, request)
  File "/home/josh/.vscode/extensions/ms-python.python-2019.3.6558/pythonFiles/lib/python/ptvsd/_vendored/pydevd/_pydevd_bundle/pydevd_process_net_command_json.py", line 177, in on_completions_request
:undefined
    self.api.request_completions(py_db, seq, thread_id, frame_id, text, line=line, column=column)
  File "/home/josh/.vscode/extensions/ms-python.python-2019.3.6558/pythonFiles/lib/python/ptvsd/_vendored/pydevd/_pydevd_bundle/pydevd_api.py", line 118, in request_completions
:undefined
    thread_id, internal_get_completions, seq, thread_id, frame_id, act_tok, line=line, column=column)
  File "/home/josh/.vscode/extensions/ms-python.python-2019.3.6558/pythonFiles/lib/python/ptvsd/_vendored/pydevd/pydevd.py", line 843, in post_method_as_internal_command
:undefined
    self.post_internal_command(internal_cmd, thread_id)
  File "/home/josh/.vscode/extensions/ms-python.python-2019.3.6558/pythonFiles/lib/python/ptvsd/_vendored/pydevd/pydevd.py", line 847, in post_internal_command
:undefined
    queue = self.get_internal_queue(thread_id)
  File "/home/josh/.vscode/extensions/ms-python.python-2019.3.6558/pythonFiles/lib/python/ptvsd/_vendored/pydevd/pydevd.py", line 834, in get_internal_queue
:undefined
    if thread_id.startswith('__frame__'):
AttributeError: 'NoneType' object has no attribute 'startswith'

Expected behavior

The debugger to run.

Other Info

I also tried the previous release, with the same issue - (61xx)

I also tried the release before that - (5xxx). The failed on another error. I can reproduce this if needed.

Steps to reproduce:

  1. Run Debug Console for Flask as per settings and launch.
setting.json ``` { "workbench.colorTheme": "Solarized Light", "explorer.confirmDragAndDrop": false, "python.pythonPath": "/home/josh/miniconda3/envs/python-data-converter-dev/bin/python", "git.confirmSync": false, "python.formatting.provider": "autopep8", "editor.formatOnSave": true, "python.linting.flake8Enabled": true, "python.unitTest.unittestEnabled": false, "python.unitTest.pyTestEnabled": true, "python.unitTest.nosetestsEnabled": false, "python.unitTest.autoTestDiscoverOnSaveEnabled": true, "python.unitTest.pyTestPath": "pytest", "python.unitTest.pyTestArgs": [ "tests", "--no-cov" ], "files.exclude": { "**/__pycache__": true, "**/.ipynb_checkpoints": true, "**/.pytest_cache": true, "**/*.egg-info": true } } ```
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": "Python: Current File (Integrated Terminal)", "type": "python", "request": "launch", "program": "${file}", "console": "integratedTerminal" }, { "name": "Python: Remote Attach", "type": "python", "request": "attach", "port": 5678, "host": "localhost", "pathMappings": [ { "localRoot": "${workspaceFolder}", "remoteRoot": "." } ] }, { "name": "Python: Module", "type": "python", "request": "launch", "module": "enter-your-module-name-here", "console": "integratedTerminal" }, { "name": "Python: Django", "type": "python", "request": "launch", "program": "${workspaceFolder}/manage.py", "console": "integratedTerminal", "args": [ "runserver", "--noreload", "--nothreading" ], "django": true }, { "name": "Python: Flask", "type": "python", "request": "launch", "module": "flask", "env": { "FLASK_APP": "data_converter/webhook.py", "FLASK_ENV": "development" }, "args": [ "run", "--no-debugger", "--no-reload" ], "jinja": true }, { "name": "Python: Current File (External Terminal)", "type": "python", "request": "launch", "program": "${file}", "console": "externalTerminal" } ] } ```
@JoshuaC3 JoshuaC3 changed the title ptvsd hangs until typing in the Debug Console then fails ptvsd hangs until typing in the Debug Console then fails with thread_id as Nonetype Apr 9, 2019
@zvictor
Copy link

zvictor commented Apr 11, 2019

I am having the same on Mac. I commented out my whole settings.json to be sure it was not a problem connected to any of my personal settings and the problem persisted.

@karthiknadig Issue #1329 did not affect me:

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/ptvsd/_vendored/pydevd/_pydevd_bundle/pydevd_comm.py", line 284, in _on_run
    self.process_net_command_json(self.global_debugger_holder.global_dbg, json_contents)
  File "/usr/local/lib/python3.7/site-packages/ptvsd/_vendored/pydevd/_pydevd_bundle/pydevd_process_net_command_json.py", line 137, in process_net_command_json
    cmd = on_request(py_db, request)
  File "/usr/local/lib/python3.7/site-packages/ptvsd/_vendored/pydevd/_pydevd_bundle/pydevd_process_net_command_json.py", line 177, in on_completions_request
    self.api.request_completions(py_db, seq, thread_id, frame_id, text, line=line, column=column)
  File "/usr/local/lib/python3.7/site-packages/ptvsd/_vendored/pydevd/_pydevd_bundle/pydevd_api.py", line 118, in request_completions
    thread_id, internal_get_completions, seq, thread_id, frame_id, act_tok, line=line, column=column)
  File "/usr/local/lib/python3.7/site-packages/ptvsd/_vendored/pydevd/pydevd.py", line 843, in post_method_as_internal_command
    self.post_internal_command(internal_cmd, thread_id)
  File "/usr/local/lib/python3.7/site-packages/ptvsd/_vendored/pydevd/pydevd.py", line 847, in post_internal_command
    queue = self.get_internal_queue(thread_id)
  File "/usr/local/lib/python3.7/site-packages/ptvsd/_vendored/pydevd/pydevd.py", line 834, in get_internal_queue
    if thread_id.startswith('__frame__'):
AttributeError: 'NoneType' object has no attribute 'startswith'

@fabioz
Copy link
Contributor

fabioz commented Apr 11, 2019

I haven't been able to reproduce, but looking at the code it seems that in on_completions_request, py_db.suspended_frames_manager.get_thread_id_for_variable_reference could return None as the thread_id if the frame_id is no longer valid (so, we should at least check if that's the case and return an error instead of showing an exception).

@fabioz fabioz self-assigned this Apr 11, 2019
@fabioz
Copy link
Contributor

fabioz commented Apr 11, 2019

As a note, I've been able to reproduce in a test case when it asks for completions of a frame which is no longer paused (so, it may be a race condition -- which we should account for).

fabioz added a commit to fabioz/ptvsd that referenced this issue Apr 12, 2019
@fabioz fabioz closed this as completed in 5e703f5 Apr 15, 2019
@SimeonRolev
Copy link

SimeonRolev commented May 3, 2019

@fabioz This issue happens to me with 2019.4.12954 too. The only difference is that it does not break when I start typing something, but when I hit Enter.

@fabioz
Copy link
Contributor

fabioz commented May 3, 2019

@SimeonRolev

Can you provide the stack trace?

A recent commit (e44dc09) fixed another issue where the thread id could be none evaluating expressions -- which I think could be the culprit in your case (same issue in a different place -- but should be fixed in master already).

@SimeonRolev
Copy link

SimeonRolev commented May 3, 2019

@fabioz I think the stack trace is the same. I just removed the Python extension and added it back, so I assume I have the latest version.

import logging
not available
Traceback (most recent call last):
  File "c:\Users\simeon rolev\.vscode\extensions\ms-python.python-2019.4.12954\pythonFiles\lib\python\ptvsd\_vendored\pydevd\_pydevd_bundle\pydevd_comm.py", line 284, in _on_run
    self.process_net_command_json(self.global_debugger_holder.global_dbg, json_contents)
  File "c:\Users\simeon rolev\.vscode\extensions\ms-python.python-2019.4.12954\pythonFiles\lib\python\ptvsd\_vendored\pydevd\_pydevd_bundle\pydevd_process_net_command_json.py", line 157, in process_net_command_json
    cmd = on_request(py_db, request)
  File "c:\Users\simeon rolev\.vscode\extensions\ms-python.python-2019.4.12954\pythonFiles\lib\python\ptvsd\_vendored\pydevd\_pydevd_bundle\pydevd_process_net_command_json.py", line 559, in on_evaluate_request
    py_db, request, thread_id)
  File "c:\Users\simeon rolev\.vscode\extensions\ms-python.python-2019.4.12954\pythonFiles\lib\python\ptvsd\_vendored\pydevd\_pydevd_bundle\pydevd_api.py", line 385, in request_exec_or_evaluate_json
    thread_id, internal_evaluate_expression_json, request, thread_id)
  File "c:\Users\simeon rolev\.vscode\extensions\ms-python.python-2019.4.12954\pythonFiles\lib\python\ptvsd\_vendored\pydevd\pydevd.py", line 873, in post_method_as_internal_command
    self.post_internal_command(internal_cmd, thread_id)
  File "c:\Users\simeon rolev\.vscode\extensions\ms-python.python-2019.4.12954\pythonFiles\lib\python\ptvsd\_vendored\pydevd\pydevd.py", line 877, in post_internal_command
    queue = self.get_internal_queue(thread_id)
  File "c:\Users\simeon rolev\.vscode\extensions\ms-python.python-2019.4.12954\pythonFiles\lib\python\ptvsd\_vendored\pydevd\pydevd.py", line 864, in get_internal_queue
    if thread_id.startswith('__frame__'):
AttributeError: 'NoneType' object has no attribute 'startswith'

@fabioz
Copy link
Contributor

fabioz commented May 3, 2019

Actually, this one is not fixed (it's in a different place: on_evaluate_request).

Created: #1401 to deal with that as it's similar but not the same thing.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants