microsoft / microsoft/vscode-python-debugger

Bug: Debug Attach stopped working in 2025.18.0

オープン
#904 コメント 8 件 リアクション 1 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

triage-needed
主要言語
TypeScript
スター
181
フォーク
126
平均マージ
2日 3時間
マージ済み PR(30日)
3

説明

Debug attach mode stopped working in 2025.18.0. When I downgrade to 2025.16.0, it works again.

Reproducer:

Launch configuration:

{
    "name": "Python Debugger: Attach using Process Id",
    "type": "debugpy",
    "request": "attach",
    "processId": "${command:pickProcess}"
}

In my SLES 15-SP4 (Linux) machine:

> python3
Python 3.12.0 (main, Oct 18 2023, 17:19:09) [GCC 7.5.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
Ctrl click to launch VS Code Native REPL
>>> import os
>>> os.getpid()
<pid of python process will be shown>

Start the debugging with the launch configuration from above and use the pid from the os.getpid(). Then observe that it will just try to attach for a minute, then give up with the following error:

Image

This is the content in the debug console:

Attach to PID failed.

--- Starting attach to pid: 141427 ---
0.00s - Debugger warning: It seems that frozen modules are being used, which may
0.00s - make the debugger miss breakpoints. Please pass -Xfrozen_modules=off
0.00s - to python to disable frozen modules.
0.00s - Note: Debugging will proceed. Set PYDEVD_DISABLE_FILE_VALIDATION=1 to disable this validation.
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
0x00007fa0655600a6 in select () from /lib64/libc.so.6
The target architecture is set to "auto" (currently "i386:x86-64").
$1 = (void *) 0x0
No symbol "DoAttach" in current context.
[Inferior 1 (process 141427) detached]
E+00000.426: Code injection into PID=141427 failed:
             
             Traceback (most recent call last):
               File "/disk2/tsonono/.vscode-server/extensions/ms-python.debugpy-2025.18.0/bundled/libs/debugpy/adapter/../../debugpy/../debugpy/server/cli.py", line 468, in attach_to_pid
                 add_code_to_python_process.run_python_code(
               File "/disk2/tsonono/.vscode-server/extensions/ms-python.debugpy-2025.18.0/bundled/libs/debugpy/_vendored/pydevd/pydevd_attach_to_process/add_code_to_python_process.py", line 483, in run_python_code_linux
                 subprocess.check_call(" ".join(cmd), shell=True, env=env)
               File "/usr/itm/python/3.12.0/lib/python3.12/subprocess.py", line 413, in check_call
                 raise CalledProcessError(retcode, cmd)
             subprocess.CalledProcessError: Command 'gdb --nw --nh --nx --pid 141427 --batch --eval-command='set scheduler-locking off' --eval-command='set architecture auto' --eval-command='call (void*)dlopen("/disk2/tsonono/.vscode-server/extensions/ms-python.debugpy-2025.18.0/bundled/libs/debugpy/_vendored/pydevd/pydevd_attach_to_process/attach_linux_amd64.so", 2)' --eval-command='sharedlibrary attach_linux_amd64' --eval-command='call (int)DoAttach(0, "import codecs;import json;import sys;decode = lambda s: codecs.utf_8_decode(bytearray(s))[0] if s is not None else None;script_dir = decode([47, 100, 105, 115, 107, 50, 47, 116, 115, 111, 110, 111, 110, 111, 47, 46, 118, 115, 99, 111, 100, 101, 45, 115, 101, 114, 118, 101, 114, 47, 101, 120, 116, 101, 110, 115, 105, 111, 110, 115, 47, 109, 115, 45, 112, 121, 116, 104, 111, 110, 46, 100, 101, 98, 117, 103, 112, 121, 45, 50, 48, 50, 53, 46, 49, 56, 46, 48, 47, 98, 117, 110, 100, 108, 101, 100, 47, 108, 105, 98, 115, 47, 100, 101, 98, 117, 103, 112, 121, 47, 97, 100, 97, 112, 116, 101, 114, 47, 46, 46, 47, 46, 46, 47, 100, 101, 98, 117, 103, 112, 121, 47, 46, 46, 47, 100, 101, 98, 117, 103, 112, 121, 47, 115, 101, 114, 118, 101, 114]);setup = json.loads(decode([123, 34, 109, 111, 100, 101, 34, 58, 32, 34, 99, 111, 110, 110, 101, 99, 116, 34, 44, 32, 34, 97, 100, 100, 114, 101, 115, 115, 34, 58, 32, 91, 34, 49, 50, 55, 46, 48, 46, 48, 46, 49, 34, 44, 32, 52, 52, 52, 56, 57, 93, 44, 32, 34, 119, 97, 105, 116, 95, 102, 111, 114, 95, 99, 108, 105, 101, 110, 116, 34, 58, 32, 102, 97, 108, 115, 101, 44, 32, 34, 108, 111, 103, 95, 116, 111, 34, 58, 32, 110, 117, 108, 108, 44, 32, 34, 97, 100, 97, 112, 116, 101, 114, 95, 97, 99, 99, 101, 115, 115, 95, 116, 111, 107, 101, 110, 34, 58, 32, 34, 97, 53, 101, 51, 51, 100, 52, 53, 50, 48, 56, 50, 51, 48, 49, 54, 53, 54, 48, 55, 57, 52, 52, 48, 57, 54, 57, 98, 48, 51, 52, 52, 102, 99, 99, 50, 56, 97, 54, 98, 57, 53, 55, 49, 55, 50, 50, 99, 54, 97, 99, 100, 48, 53, 48, 49, 54, 102, 102, 50, 99, 54, 102, 102, 34, 125]));sys.path.insert(0, script_dir);import attach_pid_injected;del sys.path[0];attach_pid_injected.attach(setup);", 0)'' returned non-zero exit status 1.
             
             Stack where logged:
               File "<frozen runpy>", line 198, in _run_module_as_main
               File "<frozen runpy>", line 88, in _run_code
               File "/disk2/tsonono/.vscode-server/extensions/ms-python.debugpy-2025.18.0/bundled/libs/debugpy/adapter/../../debugpy/__main__.py", line 71, in <module>
                 cli.main()
               File "/disk2/tsonono/.vscode-server/extensions/ms-python.debugpy-2025.18.0/bundled/libs/debugpy/adapter/../../debugpy/../debugpy/server/cli.py", line 508, in main
                 run()
               File "/disk2/tsonono/.vscode-server/extensions/ms-python.debugpy-2025.18.0/bundled/libs/debugpy/adapter/../../debugpy/../debugpy/server/cli.py", line 475, in attach_to_pid
                 log.reraise_exception("Code injection into PID={0} failed:", pid)
               File "/disk2/tsonono/.vscode-server/extensions/ms-python.debugpy-2025.18.0/bundled/libs/debugpy/adapter/../../debugpy/../debugpy/common/log.py", line 222, in reraise_exception
                 _exception(format_string, *args, **kwargs)
             

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/disk2/tsonono/.vscode-server/extensions/ms-python.debugpy-2025.18.0/bundled/libs/debugpy/adapter/../../debugpy/__main__.py", line 71, in <module>
    cli.main()
  File "/disk2/tsonono/.vscode-server/extensions/ms-python.debugpy-2025.18.0/bundled/libs/debugpy/adapter/../../debugpy/../debugpy/server/cli.py", line 508, in main
    run()
  File "/disk2/tsonono/.vscode-server/extensions/ms-python.debugpy-2025.18.0/bundled/libs/debugpy/adapter/../../debugpy/../debugpy/server/cli.py", line 475, in attach_to_pid
    log.reraise_exception("Code injection into PID={0} failed:", pid)
  File "/disk2/tsonono/.vscode-server/extensions/ms-python.debugpy-2025.18.0/bundled/libs/debugpy/adapter/../../debugpy/../debugpy/server/cli.py", line 468, in attach_to_pid
    add_code_to_python_process.run_python_code(
  File "/disk2/tsonono/.vscode-server/extensions/ms-python.debugpy-2025.18.0/bundled/libs/debugpy/_vendored/pydevd/pydevd_attach_to_process/add_code_to_python_process.py", line 483, in run_python_code_linux
    subprocess.check_call(" ".join(cmd), shell=True, env=env)
  File "/usr/itm/python/3.12.0/lib/python3.12/subprocess.py", line 413, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command 'gdb --nw --nh --nx --pid 141427 --batch --eval-command='set scheduler-locking off' --eval-command='set architecture auto' --eval-command='call (void*)dlopen("/disk2/tsonono/.vscode-server/extensions/ms-python.debugpy-2025.18.0/bundled/libs/debugpy/_vendored/pydevd/pydevd_attach_to_process/attach_linux_amd64.so", 2)' --eval-command='sharedlibrary attach_linux_amd64' --eval-command='call (int)DoAttach(0, "import codecs;import json;import sys;decode = lambda s: codecs.utf_8_decode(bytearray(s))[0] if s is not None else None;script_dir = decode([47, 100, 105, 115, 107, 50, 47, 116, 115, 111, 110, 111, 110, 111, 47, 46, 118, 115, 99, 111, 100, 101, 45, 115, 101, 114, 118, 101, 114, 47, 101, 120, 116, 101, 110, 115, 105, 111, 110, 115, 47, 109, 115, 45, 112, 121, 116, 104, 111, 110, 46, 100, 101, 98, 117, 103, 112, 121, 45, 50, 48, 50, 53, 46, 49, 56, 46, 48, 47, 98, 117, 110, 100, 108, 101, 100, 47, 108, 105, 98, 115, 47, 100, 101, 98, 117, 103, 112, 121, 47, 97, 100, 97, 112, 116, 101, 114, 47, 46, 46, 47, 46, 46, 47, 100, 101, 98, 117, 103, 112, 121, 47, 46, 46, 47, 100, 101, 98, 117, 103, 112, 121, 47, 115, 101, 114, 118, 101, 114]);setup = json.loads(decode([123, 34, 109, 111, 100, 101, 34, 58, 32, 34, 99, 111, 110, 110, 101, 99, 116, 34, 44, 32, 34, 97, 100, 100, 114, 101, 115, 115, 34, 58, 32, 91, 34, 49, 50, 55, 46, 48, 46, 48, 46, 49, 34, 44, 32, 52, 52, 52, 56, 57, 93, 44, 32, 34, 119, 97, 105, 116, 95, 102, 111, 114, 95, 99, 108, 105, 101, 110, 116, 34, 58, 32, 102, 97, 108, 115, 101, 44, 32, 34, 108, 111, 103, 95, 116, 111, 34, 58, 32, 110, 117, 108, 108, 44, 32, 34, 97, 100, 97, 112, 116, 101, 114, 95, 97, 99, 99, 101, 115, 115, 95, 116, 111, 107, 101, 110, 34, 58, 32, 34, 97, 53, 101, 51, 51, 100, 52, 53, 50, 48, 56, 50, 51, 48, 49, 54, 53, 54, 48, 55, 57, 52, 52, 48, 57, 54, 57, 98, 48, 51, 52, 52, 102, 99, 99, 50, 56, 97, 54, 98, 57, 53, 55, 49, 55, 50, 50, 99, 54, 97, 99, 100, 48, 53, 48, 49, 54, 102, 102, 50, 99, 54, 102, 102, 34, 125]));sys.path.insert(0, script_dir);import attach_pid_injected;del sys.path[0];attach_pid_injected.attach(setup);", 0)'' returned non-zero exit status 1.
PYDEVD_GDB_SCAN_SHARED_LIBRARIES not set (scanning all libraries for needed symbols).
Running: gdb --nw --nh --nx --pid 141427 --batch --eval-command='set scheduler-locking off' --eval-command='set architecture auto' --eval-command='call (void*)dlopen("/disk2/tsonono/.vscode-server/extensions/ms-python.debugpy-2025.18.0/bundled/libs/debugpy/_vendored/pydevd/pydevd_attach_to_process/attach_linux_amd64.so", 2)' --eval-command='sharedlibrary attach_linux_amd64' --eval-command='call (int)DoAttach(0, "import codecs;import json;import sys;decode = lambda s: codecs.utf_8_decode(bytearray(s))[0] if s is not None else None;script_dir = decode([47, 100, 105, 115, 107, 50, 47, 116, 115, 111, 110, 111, 110, 111, 47, 46, 118, 115, 99, 111, 100, 101, 45, 115, 101, 114, 118, 101, 114, 47, 101, 120, 116, 101, 110, 115, 105, 111, 110, 115, 47, 109, 115, 45, 112, 121, 116, 104, 111, 110, 46, 100, 101, 98, 117, 103, 112, 121, 45, 50, 48, 50, 53, 46, 49, 56, 46, 48, 47, 98, 117, 110, 100, 108, 101, 100, 47, 108, 105, 98, 115, 47, 100, 101, 98, 117, 103, 112, 121, 47, 97, 100, 97, 112, 116, 101, 114, 47, 46, 46, 47, 46, 46, 47, 100, 101, 98, 117, 103, 112, 121, 47, 46, 46, 47, 100, 101, 98, 117, 103, 112, 121, 47, 115, 101, 114, 118, 101, 114]);setup = json.loads(decode([123, 34, 109, 111, 100, 101, 34, 58, 32, 34, 99, 111, 110, 110, 101, 99, 116, 34, 44, 32, 34, 97, 100, 100, 114, 101, 115, 115, 34, 58, 32, 91, 34, 49, 50, 55, 46, 48, 46, 48, 46, 49, 34, 44, 32, 52, 52, 52, 56, 57, 93, 44, 32, 34, 119, 97, 105, 116, 95, 102, 111, 114, 95, 99, 108, 105, 101, 110, 116, 34, 58, 32, 102, 97, 108, 115, 101, 44, 32, 34, 108, 111, 103, 95, 116, 111, 34, 58, 32, 110, 117, 108, 108, 44, 32, 34, 97, 100, 97, 112, 116, 101, 114, 95, 97, 99, 99, 101, 115, 115, 95, 116, 111, 107, 101, 110, 34, 58, 32, 34, 97, 53, 101, 51, 51, 100, 52, 53, 50, 48, 56, 50, 51, 48, 49, 54, 53, 54, 48, 55, 57, 52, 52, 48, 57, 54, 57, 98, 48, 51, 52, 52, 102, 99, 99, 50, 56, 97, 54, 98, 57, 53, 55, 49, 55, 50, 50, 99, 54, 97, 99, 100, 48, 53, 48, 49, 54, 102, 102, 50, 99, 54, 102, 102, 34, 125]));sys.path.insert(0, script_dir);import attach_pid_injected;del sys.path[0];attach_pid_injected.attach(setup);", 0)'

The gdb version on my host if 14.2, if that's of any relevance, as the debugger is seemingly using the host's gdb based on the output in the debug console.

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

提供された起動構成、Python 3.12 プロセス、SLES 15-SP4 環境、および host gdb を使って attach の失敗を再現します。debugpy/server/cli.py、pydevd_attach_to_process/add_code_to_python_process.py、および attach_linux_amd64.so に関連する traceback を読みます。完了条件は、報告された injection エラーなしで 2025.18.0 で PID attach が機能することです。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
linux, python, vscode
領域
devtools, operating-systems
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
説明が足りない
初心者へのやさしさ
30/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。