Debugger Hangs on check_output
Closed this issue · 8 comments
from subprocess import check_output
command = r'dir'
output = check_output(command, shell=True)
print(output)
This hangs in the debugger in 2024.12.0. However, it runs as expected from the command line outside of vscode.
Works fine in 2024.10.0.
Hi! Can you include the config you use from launch.json to run this in the debugger? Do you know which line it hangs on in the debugger?
{
"version": "0.2.0",
"configurations": [
{
"name": "Py",
"type": "debugpy",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
},
{
"name": "Py redirect",
"type": "debugpy",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
"args": [">", "${relativeFileDirname}/output.txt"]
},
]
}
Windows 10 Pro 64-bit
Python 3.12.2 64-bit
VS Code 1.95.2
As stated, debugger hangs attempting to execute this command:
output = check_output(command, shell=True)
Regression. Runs without issue using version 2024.10.0. Consistently hangs using version 2024.12.0.
I was running into a similar issue. I had consistent reproduction with a similar script, though mine used Popen.
As a one-liner: import subprocess;subprocess.Popen(["git"]).communicate()
I narrowed down where things were blocking. It was line 1205 of subprocess.py: https://github.com/python/cpython/blob/6da9d252ac39d53342455a17bfec7b1087fba697/Lib/subprocess.py#L1205
It just never returned.
However, I tried to reproduce @1John419's example, including using Python 3.12.2. This involved deleting my virtual environment. Since then, I've been unable to reproduce the issue of subprocess not returning. So maybe it was some weird caching issue? Hard to know really, but like John, I only had the behaviour with 2024.12.0 and not with 2024.10.0.
I still have an issue that seems related (let me know if you want a distinct ticket for it).
When I change "git" to a command that is invalid, pydevd raises an exception.
[14:18:15.406]-[D:/git/transcription-bot]-[add-wiki-maintenance]-[✓ 64ms]
└─$ & 'd:\git\transcription-bot\.venv\Scripts\python.exe' 'c:\Users\Matthew\.vscode\extensions\ms-python.debugpy-2024.12.0-win32-x64\bundled\libs\debugpy\adapter/../..\debugpy\launcher' '58371' '--' 'D:\git\transcription-bot\repro.py'
0.42s - Error on build_exception_info_response.
Traceback (most recent call last):
File "c:\Users\Matthew\.vscode\extensions\ms-python.debugpy-2024.12.0-win32-x64\bundled\libs\debugpy\_vendored\pydevd\_pydevd_bundle\pydevd_comm.py", line 1533, in build_exception_info_response
stack_str = "".join(stack_summary.format())
~~~~~~~~~~~~~~~~~~~~^^
File "C:\Users\Matthew\AppData\Roaming\uv\python\cpython-3.13.0-windows-x86_64-none\Lib\traceback.py", line 749, in format
formatted_frame = self.format_frame_summary(frame_summary, colorize=colorize)
File "C:\Users\Matthew\AppData\Roaming\uv\python\cpython-3.13.0-windows-x86_64-none\Lib\traceback.py", line 553, in format_frame_summary
last_line = all_lines_original[frame_summary.end_lineno - frame_summary.lineno]
~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
IndexError: list index out of range
Traceback (most recent call last):
File "C:\Users\Matthew\AppData\Roaming\uv\python\cpython-3.13.0-windows-x86_64-none\Lib\runpy.py", line 198, in _run_module_as_main
return _run_code(code, main_globals, None,
"__main__", mod_spec)
File "C:\Users\Matthew\AppData\Roaming\uv\python\cpython-3.13.0-windows-x86_64-none\Lib\runpy.py", line 88, in _run_code
exec(code, run_globals)
~~~~^^^^^^^^^^^^^^^^^^^
File "c:\Users\Matthew\.vscode\extensions\ms-python.debugpy-2024.12.0-win32-x64\bundled\libs\debugpy\adapter/../..\debugpy\launcher/../..\debugpy\__main__.py", line 71, in <module>
cli.main()
~~~~~~~~^^
File "c:\Users\Matthew\.vscode\extensions\ms-python.debugpy-2024.12.0-win32-x64\bundled\libs\debugpy\adapter/../..\debugpy\launcher/../..\debugpy/..\debugpy\server\cli.py", line 501, in main
run()
~~~^^
File "c:\Users\Matthew\.vscode\extensions\ms-python.debugpy-2024.12.0-win32-x64\bundled\libs\debugpy\adapter/../..\debugpy\launcher/../..\debugpy/..\debugpy\server\cli.py", line 351, in run_file
runpy.run_path(target, run_name="__main__")
~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "c:\Users\Matthew\.vscode\extensions\ms-python.debugpy-2024.12.0-win32-x64\bundled\libs\debugpy\_vendored\pydevd\_pydevd_bundle\pydevd_runpy.py", line 310, in run_path
return _run_module_code(code, init_globals, run_name, pkg_name=pkg_name, script_name=fname)
File "c:\Users\Matthew\.vscode\extensions\ms-python.debugpy-2024.12.0-win32-x64\bundled\libs\debugpy\_vendored\pydevd\_pydevd_bundle\pydevd_runpy.py", line 127, in _run_module_code
_run_code(code, mod_globals, init_globals, mod_name, mod_spec, pkg_name, script_name)
~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "c:\Users\Matthew\.vscode\extensions\ms-python.debugpy-2024.12.0-win32-x64\bundled\libs\debugpy\_vendored\pydevd\_pydevd_bundle\pydevd_runpy.py", line 118, in _run_code
exec(code, run_globals)
~~~~^^^^^^^^^^^^^^^^^^^
File "D:\git\transcription-bot\repro.py", line 3, in <module>
subprocess.Popen(["bloopsie"], stdout=subprocess.PIPE).communicate()
~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Matthew\AppData\Roaming\uv\python\cpython-3.13.0-windows-x86_64-none\Lib\subprocess.py", line 1035, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pass_fds, cwd, env,
^^^^^^^^^^^^^^^^^^^
...<5 lines>...
gid, gids, uid, umask,
^^^^^^^^^^^^^^^^^^^^^^
start_new_session, process_group)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Matthew\AppData\Roaming\uv\python\cpython-3.13.0-windows-x86_64-none\Lib\subprocess.py", line 1547, in _execute_child
hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^
# no special security
^^^^^^^^^^^^^^^^^^^^^
...<4 lines>...
cwd,
^^^^
startupinfo)
^^^^^^^^^^^^
File "c:\Users\Matthew\.vscode\extensions\ms-python.debugpy-2024.12.0-win32-x64\bundled\libs\debugpy\_vendored\pydevd\_pydev_bundle\pydev_monkey.py", line 914, in new_CreateProcess
return getattr(_subprocess, original_name)(app_name, cmd_line, *args)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [WinError 2] The system cannot find the file specified
My setup:
Windows 11 Pro version 23H2
Python 3.13.0
Extension 2024.12.0
@mheguy, do you see the same issue where this is specifically a regression or do you see the bug on the earlier version of the extension too?
I would hazard a guess this is a bug that was fixed in the latest version of debugpy where we changed how we debug 3.12 and 3.13 code. I can't reproduce the issue.
Sorry to report that this issue still exists in v2024.12.0...
Sorry but that's not the latest version. You'd have to install the prerelease version.
OK, thanks for clarifying. Issue not observed in pre-release.