Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Specific characters in path of parent directories of file causes debugger to crash.

Đang mở
#1,671 7 bình luận 1 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
28/100
Loại issue
Lỗi
Độ rõ ràng
Cần làm rõ
Mức độ hoạt động
Đình trệ
Công nghệ
python
Lĩnh vực
devtools

Hướng nghiên cứu

Bắt đầu bằng cách tái hiện lỗi với các đường dẫn và lệnh của thư mục cha trong báo cáo, sau đó lần theo traceback qua các entry point debugpy/launcher, server/cli.py và pydevd_runpy.py vendored. Được coi là hoàn tất khi việc debug hoạt động với các tệp nằm dưới những thư mục chứa các ký tự được báo cáo mà không xảy ra lỗi shell hoặc FileNotFoundError; issue không nêu tên một test của repository hay tệp triển khai.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

bug
Summary

I've managed to break the path parsing. Specifically, including certain characters in the parent directories of the file being debugged causes the debugger to crash.

I don't know what specific characters cause this, but I'll update the report when(/if) I do.

Reproduction
  1. Directory-Caused Crash

    The undermentioned path, which contains a normal filename (testfile.py) but an abnormally named immediate parent directory:

    /home/RokeJulianLockhart/Documents/  [-]	`{title: "Code",	id: ""}`{.JSON5}.dir/testfile.py
    

    ...causes ms-python.debugpy to crash:

    RokeJulianLockhart@sayw4i:~/Documents$  cd /home/RokeJulianLockhart/Documents/\ \ \[-\]\`\{title:\ \"Code\",id:\ \"\"\}\`\{.JSON5\}.dir ; /usr/bin/env /usr/bin/python3 /home/RokeJulianLockhart/.vscode-insiders/extensions/ms-python.debugpy-2024.11.2024082901-linux-x64/bundled/libs/debugpy/adapter/../../debugpy/launcher 47225 -- /home/RokeJulianLockhart/Documents/\ \ \[-\]\`\{title:\ \"Code\",id:\ \"\"\}\`\{.JSON5\}.dir/testfile.py 
    bash: cd: /home/RokeJulianLockhart/Documents/  [-]`{title: "Code",id: ""}`{.JSON5}.dir: No such file or directory
    Traceback (most recent call last):
      File "/usr/lib64/python3.12/runpy.py", line 198, in _run_module_as_main
        return _run_code(code, main_globals, None,
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/usr/lib64/python3.12/runpy.py", line 88, in _run_code
        exec(code, run_globals)
      File "/home/RokeJulianLockhart/.vscode-insiders/extensions/ms-python.debugpy-2024.11.2024082901-linux-x64/bundled/libs/debugpy/adapter/../../debugpy/launcher/../../debugpy/__main__.py", line 71, in <module>
        cli.main()
      File "/home/RokeJulianLockhart/.vscode-insiders/extensions/ms-python.debugpy-2024.11.2024082901-linux-x64/bundled/libs/debugpy/adapter/../../debugpy/launcher/../../debugpy/../debugpy/server/cli.py", line 486, in main
        run()
      File "/home/RokeJulianLockhart/.vscode-insiders/extensions/ms-python.debugpy-2024.11.2024082901-linux-x64/bundled/libs/debugpy/adapter/../../debugpy/launcher/../../debugpy/../debugpy/server/cli.py", line 336, in run_file
        runpy.run_path(target, run_name="__main__")
      File "/home/RokeJulianLockhart/.vscode-insiders/extensions/ms-python.debugpy-2024.11.2024082901-linux-x64/bundled/libs/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_runpy.py", line 320, in run_path
        code, fname = _get_code_from_file(run_name, path_name)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/home/RokeJulianLockhart/.vscode-insiders/extensions/ms-python.debugpy-2024.11.2024082901-linux-x64/bundled/libs/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_runpy.py", line 289, in _get_code_from_file
        with io_open_code(decoded_path) as f:
             ^^^^^^^^^^^^^^^^^^^^^^^^^^
    FileNotFoundError: [Errno 2] No such file or directory: '/home/RokeJulianLockhart/Documents/  [-]`{title: "Code",id: ""}`{.JSON5}.dir/testfile.py'
    RokeJulianLockhart@sayw4i:~/Documents$
    

    Merely one directory in the absolute path of the file need contain such characters for the parsing to fail, as the undermentioned "Terminal" log from ms-python.debugpy demonstrates:

    RokeJulianLockhart@sayw4i:~/Documents$  cd /home/RokeJulianLockhart/Documents/\ \ \[-\]\`\{title:\ \"Code\",id:\ \"\"\}\`\{.JSON5\}.dir/test_directory ; /usr/bin/env /usr/bin/python3 /home/RokeJulianLockhart/.vscode-insiders/extensions/ms-python.debugpy-2024.11.2024082901-linux-x64/bundled/libs/debugpy/adapter/../../debugpy/launcher 47783 -- /home/RokeJulianLockhart/Documents/\ \ \[-\]\`\{title:\ \"Code\",id:\ \"\"\}\`\{.JSON5\}.dir/test_directory/test_file.py 
    bash: cd: /home/RokeJulianLockhart/Documents/  [-]`{title: "Code",id: ""}`{.JSON5}.dir/test_directory: No such file or directory
    Traceback (most recent call last):
      File "/usr/lib64/python3.12/runpy.py", line 198, in _run_module_as_main
        return _run_code(code, main_globals, None,
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/usr/lib64/python3.12/runpy.py", line 88, in _run_code
        exec(code, run_globals)
      File "/home/RokeJulianLockhart/.vscode-insiders/extensions/ms-python.debugpy-2024.11.2024082901-linux-x64/bundled/libs/debugpy/adapter/../../debugpy/launcher/../../debugpy/__main__.py", line 71, in <module>
        cli.main()
      File "/home/RokeJulianLockhart/.vscode-insiders/extensions/ms-python.debugpy-2024.11.2024082901-linux-x64/bundled/libs/debugpy/adapter/../../debugpy/launcher/../../debugpy/../debugpy/server/cli.py", line 486, in main
        run()
      File "/home/RokeJulianLockhart/.vscode-insiders/extensions/ms-python.debugpy-2024.11.2024082901-linux-x64/bundled/libs/debugpy/adapter/../../debugpy/launcher/../../debugpy/../debugpy/server/cli.py", line 336, in run_file
        runpy.run_path(target, run_name="__main__")
      File "/home/RokeJulianLockhart/.vscode-insiders/extensions/ms-python.debugpy-2024.11.2024082901-linux-x64/bundled/libs/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_runpy.py", line 320, in run_path
        code, fname = _get_code_from_file(run_name, path_name)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/home/RokeJulianLockhart/.vscode-insiders/extensions/ms-python.debugpy-2024.11.2024082901-linux-x64/bundled/libs/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_runpy.py", line 289, in _get_code_from_file
        with io_open_code(decoded_path) as f:
             ^^^^^^^^^^^^^^^^^^^^^^^^^^
    FileNotFoundError: [Errno 2] No such file or directory: '/home/RokeJulianLockhart/Documents/  [-]`{title: "Code",id: ""}`{.JSON5}.dir/test_directory/test_file.py'
    RokeJulianLockhart@sayw4i:~/Documents$
    
  2. If I put the file deep enough (like this example) it completely breaks. Enter doesn't work because the path is incorrectly escaped, so ^C is necessary to exit the transient debug state:

    RokeJulianLockhart@sayw4i:~/Software/Git/GitLab.com/RokeJulianLockhart/sg5n9q/  [-]     `{title: "Non-Metadata",        id: "s1gvg2"}`{.JSON5}.dir/  [-]        `{title: "Technical",   id: "s20cxw"}`{.JSON5}.dir/  [-]        `{title: "Applications",        id: ""}`{.JSON5}.dir/  [-] `{title: "Configurator",        id: "s3wrcl"}`{.JSON5}.dir/  [-]        `{title: "Code",        id: ""}`{.JSON5}.dir$  cd /home/RokeJulianLockhart/Software/Git/GitLab.com/RokeJulianLockhart/sg5n9q/\ \ \[-]\ `\{title\:\ \"\`\{title:\ \"Non-Metadata\",id:\ \"s1gvg2\"\}\`\{.JSON5\}.dir/\ \ \[-\]\`\{title:\ \"Technical\",id:\ \"s20cxw\"\}\`\{.JSON5\}.dir/\ \ \[-\]\`\{title:\ \"Applications\",id:\ \"\"\}\`\{.JSON5\}.dir/\ \ \[-\]\`\{title:\ \"Configurator\",id:\ \"s3wrcl\"\}\`\{.JSON5\}.dir/\ \ \[-\]\`\{title:\ \"Code\",id:\ \"\"\}\`\{.JSON5\}.dir ; /usr/bin/env /usr/bin/python3 /home/RokeJulianLockhart/.vscode-insiders/extensions/ms-python.debugpy-2024.11.2024082901-linux-x64/bundled/libs/debugpy/adapter/../../debugpy/launcher 39897 -- /home/RokeJulianLockhart/Software/Git/GitLab.com/RokeJulianLockhart/sg5n9q/\ \ \[-\]\`\{title:\ \"Non-Metadata\",id:\ \"s1gvg2\"\}\`\{.JSON5\}.dir/\ \ \[-\]\`\{title:\ \"Technical\",id:\ \"s20cxw\"\}\`\{.JSON5\}.dir/\ \ \[-\]\`\{title:\ \"Applications\",id:\ \"\"\}\`\{.JSON5\}.dir/\ \ \[-\]\`\{title:\ \"Configurator\",id:\ \"s3wrcl\"\}\`\{.JSON5\}.dir/\ \ \[-\]\`\{title:\ \"Code\",id:\ \"\"\}\`\{.JSON5\}.dir/.\ \[-\]\`\`\{title:\ \"\`platform.uname\(\)\`\{.Py\}\ Field\ Output\",id:\ \"sgskr5\"\}\`\`\{.JSON5\}.txt.Py 
    > 
    > ^C
    RokeJulianLockhart@sayw4i:~/Software/Git/GitLab.com/RokeJulianLockhart/sg5n9q/  [-]     `{title: "Non-Metadata",        id: "s1gvg2"}`{.JSON5}.dir/  [-]        `{title: "Technical",   id: "s20cxw"}`{.JSON5}.dir/  [-]        `{title: "Applications",        id: ""}`{.JSON5}.dir/  [-] `{title: "Configurator",        id: "s3wrcl"}`{.JSON5}.dir/  [-]        `{title: "Code",        id: ""}`{.JSON5}.dir$
    

    This causes https://github.com/microsoft/debugpy/issues/1677 to occur:

    Screenshot_20240914_145708

  3. Debugger Functioning with Unusual Filename

    Note that this doesn't apply to the file's name. Consider the undermentioned example:

    /home/RokeJulianLockhart/Documents/. [-]	``{title: "`platform.uname()`{.Py} Field Output",	id: "sgskr5"}``{.JSON5}.txt.Py
    

    As the undermentioned "Terminal" log demonstrates, it functions:

    RokeJulianLockhart@sayw4i:~/Documents$  cd /home/RokeJulianLockhart/Documents ; /usr/bin/env /usr/bin/python3 /home/RokeJulianLockhart/.vscode-insiders/extensions/ms-python.debugpy-2024.11.2024082901-linux-x64/bundled/libs/debugpy/adapter/../../debugpy/launcher 38369 -- /home/RokeJulianLockhart/Documents/.\ \[-\]\        \`\`\{title\:\ \"\`platform.uname\(\)\`\{.Py\}\ Field\ Output\"\,\      id\:\ \"sgskr5\"\}\`\`\{.JSON5\}.txt.Py \`\`\{title:\ \"\`platform.uname\(\)\`\{.Py\}\ Field\ Output\",id:\ \"sgskr5\"\}\`\`\{.JSON5\}.txt.Py 
    for k, v in platform_uname_as_dict.items()
    system = Linux
    node = sayw4i
    release = 6.10.10-200.fc40.x86_64
    version = microsoft/vscode-python-debugger#1 SMP PREEMPT_DYNAMIC Thu Sep 12 18:26:09 UTC 2024
    machine = x86_64
    processor = 
    RokeJulianLockhart@sayw4i:~/Documents$
    
Environment
  1. Filename Character Support

    One must be using a filesystem and OS that support such characters. I use BTRFS on Fedora 40, but anything comparable should work. ^2

  2. Versions
    1. Code
      1. #!/usr/bin/env sh
        rpm -q 'code' 'code-insiders'
        
      2. code-1.93.1-1726079369.el8.x86_64
        code-insiders-1.94.0-1726207949.el8.x86_64
        
    2. Debugger

      marketplace.visualstudio.com/_apis/public/gallery/publishers/ms-python/vsextensions/debugpy/2024.11.2024082901/vspackage?targetPlatform=linux-x64 ^1

Miscellaneous

Potentially related to https://github.com/microsoft/vscode-python-debugger/issues/233#issue-2152958262, although I doubt it, because /home/RokeJulianLockhart/Documents/Text File.txt.py works.

Ngôn ngữ chính
Python
Star
2.5k
Fork
202
Merge trung bình
5 ngày 1 giờ
Pull request đã merge (30 ngày)
1

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của microsoft/debugpy

Tất cả issue của microsoft/debugpy

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.