microsoft / microsoft/vscode-python-debugger

Bug: Debug Attach stopped working in 2025.18.0

未關閉
#904 8 則留言 1 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

triage-needed
主要語言
TypeScript
星號
181
分支
126
平均合併
2 天 3 小時
30 天內合併 PR
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. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 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;完成標準是在 2025.18.0 中 PID attach 能夠正常運作,且沒有回報的 injection 錯誤。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
linux, python, vscode
領域
devtools, operating-systems
Issue 類型
缺陷
難度
4/5
預估耗時
3-5 天
活躍度
停滯
描述清晰度
需要釐清
新手友好度
30/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。