본문 바로가기
Errors

[VSCode] WSL2에서 process에 attach모드로 debugging 안됨.

by ds31x 2023. 6. 26.
The futex facility returned an unexpected error code.

 

 

vscode에서 python extension을 통해 디버깅 기능 테스트 중,

 

launch로 동작은 문제 없으나, attach는 문제가 있음을 확인함.

 

wsl2 의 version

WSL version: 1.2.5.0
Kernel version: 5.15.90.1
WSLg version: 1.0.51
MSRDC version: 1.2.3770
Direct3D version: 1.608.2-61064218
DXCore version: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp
Windows version: 10.0.25393.1

 

linux distribution

$ cat /etc/*release*

PRETTY_NAME="Debian GNU/Linux 12 (bookworm)"
NAME="Debian GNU/Linux"
VERSION_ID="12"
VERSION="12 (bookworm)"
VERSION_CODENAME=bookworm
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"

 


우선 wsl2 이고 Debian distribution이 설치된 상태에서

 

mamba install debugpy 를 수행하여 debugpy를 설치한 이후,

 

다음으로 debug설정을 위한 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: Attach using Process Id",
            "type": "python",
            "request": "attach",
            "processId": "${command:pickProcess}",
            "justMyCode": true
        },
        {
            "name": "Python: Current File (External Terminal)",
            "type": "python",
            "request": "launch",
            "program": "${file}",
            "console": "externalTerminal",
            "justMyCode": true
        }
    ]
}

 

다음의 code의 python script file을 local_script_debuggin.py로 저장한 후

import debugpy

# 5678 is the default attach port in the VS Code debug configurations. Unless a host and port are specified, host defaults to 127.0.0.1
debugpy.listen(5678)
print("Waiting for debugger attach")
debugpy.wait_for_client()
debugpy.breakpoint()
print('break on this line')

 

Terminal (wt.exe)에서 다음과 같이 python으로 위의 local_script_debugging.py를 수행하고

$  python local_script_deugging.py
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.
Waiting for debugger attach

vscode에서 Python: Attach using Process Id를 디버깅했더니 Debug CONSole에서는 다음과 같이 출력이 되고

python local_script_deugging.py을 수행한 터미널에서 다음과 같이 에러가 발생.

$ python local_script_deugging.py
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.
Waiting for debugger attach
The futex facility returned an unexpected error code.
Aborted

futex 관련 에러로 보이는데... WSL2의 문제로 보인다.
(구글링 후 몇가지를 시도해봤지만 어림없었음. ㅠㅠ)

728x90