Microsoft MVP성태의 닷넷 이야기
글쓴 사람
정성태 (seongtaejeong at gmail.com)
홈페이지
첨부 파일
 

(시리즈 글이 2개 있습니다.)
디버깅 기술: 170. WinDbg Preview 버전부터 닷넷 코어 3.0 이후의 메모리 덤프에 대해 sos.dll 자동 로드
; https://www.sysnet.pe.kr/2/0/12316

오류 유형: 949. WinDbg - .NET Core/5+ 응용 프로그램 디버깅 시 sos 확장을 자동으로 로드하지 못하는 문제
; https://www.sysnet.pe.kr/2/0/13911




WinDbg - .NET Core/5+ 응용 프로그램 디버깅 시 sos 확장을 자동으로 로드하지 못하는 문제

이상하군요, 분명히 예전에는 StoreApp 유형의 WinDbg부터 .NET Core 3.0+ 응용 프로그램에 대해 sos 확장을 자동으로 로딩했었습니다.

WinDbg Preview 버전부터 닷넷 코어 3.0 이후의 메모리 덤프에 대해 sos.dll 자동 로드
; https://www.sysnet.pe.kr/2/0/12316

그런데, 현재의 (1.2502.25002.0 버전의) WinDbg에서 .NET 8 응용 프로그램에 대해 덤프를 로드했더니 다음과 같은 오류가 떨어집니다.

...[생략]...
ModLoad: 00007ffa`feae0000 00007ffa`fefbd000   C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.14\coreclr.dll
The call to LoadLibrary(sos) failed, Win32 error 0n2
    "The system cannot find the file specified."
Please check your debugger configuration and/or network access.
Extension DLL search Path:
    ...[생략]...
You may also consider deploying your extension to the UserExtensions extension gallery repository
located at %LOCALAPPDATA%\dbg\UserExtensions folder. It would require an extension manifest.
Error: Failed to load extension sos

coreclr.dll이 로드된 시점에 WinDbg가 자동으로 sos.dll을 로드하려고 시도한 듯한데, 관련 DLL을 찾지 못한 것입니다. 당연히 sos 관련 명령어가 실행되지도 않고,

0:000>  !soshelp
soshelp is not extension gallery command
No export soshelp found

0:000> !clrstack
clrstack is not extension gallery command
No export clrstack found

DLL 자체도 로딩이 안 돼 있습니다.

0:000> .chain
Extension DLL search Path:
    ...[생략]...
Extension DLL chain:
    CLRComposition: image 10.0.27793.1000, API 0.0.0, 
        [path: C:\Program Files\WindowsApps\Microsoft.WinDbg_1.2502.25002.0_x64__8wekyb3d8bbwe\amd64\winext\CLRComposition.dll]
    dbghelp: image 10.0.27793.1000, API 10.0.6, 
        [path: C:\Program Files\WindowsApps\Microsoft.WinDbg_1.2502.25002.0_x64__8wekyb3d8bbwe\amd64\dbghelp.dll]
    exts: image 10.0.27793.1000, API 1.0.0, 
        [path: C:\Program Files\WindowsApps\Microsoft.WinDbg_1.2502.25002.0_x64__8wekyb3d8bbwe\amd64\WINXP\exts.dll]
    uext: image 10.0.27793.1000, API 1.0.0, 
        [path: C:\Program Files\WindowsApps\Microsoft.WinDbg_1.2502.25002.0_x64__8wekyb3d8bbwe\amd64\winext\uext.dll]
    ntsdexts: image 10.0.27793.1000, API 1.0.0, 
        [path: C:\Program Files\WindowsApps\Microsoft.WinDbg_1.2502.25002.0_x64__8wekyb3d8bbwe\amd64\WINXP\ntsdexts.dll]

참고로, 이러한 오류 메시지는 ".loadby sos coreclr" 명령어의 결과와도 같습니다.

0:000> .loadby sos coreclr
The call to LoadLibrary(C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.14\sos.dll) failed, Win32 error 0n126
    "The specified module could not be found."
Please check your debugger configuration and/or network access.
Extension DLL search Path:
    ...[생략]...
You may also consider deploying your extension to the UserExtensions extension gallery repository
located at %LOCALAPPDATA%\dbg\UserExtensions folder. It would require an extension manifest.
Error: Failed to load extension C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.14\sos.dll

한 가지 약간 다른 점이 있다면 "C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.14\sos.dll"을 명시적으로 로드하려고 시도했다는 것입니다. (해당 위치에는 sos.dll 파일이 없었습니다.)




어쩔 수 없군요, 이렇게 된 이상 sos.dll을 수동으로 로드해야 합니다.

윈도우용 .NET Core 3 이상에서 Windbg의 sos 사용법
; https://www.sysnet.pe.kr/2/0/12641

따라서 dotnet-sos를 설치하고,

// (낮은 버전은 불가능하고,) 높은 버전이라면 지정 가능
// dotnet tool install -g dotnet-sos --version 9.0.607501

c:\temp> dotnet tool install -g dotnet-sos
You can invoke the tool using the following command: dotnet-sos
Tool 'dotnet-sos' (version '9.0.607501') was successfully installed.

이를 통해 sos.dll을 다운로드할 수 있습니다.

c:\temp> echo %USERPROFILE%
C:\Users\testusr

c:\temp;gt; dotnet-sos install
Installing SOS to C:\Users\testusr\.dotnet\sos
Creating installation directory...
Copying files from C:\Users\testusr\.dotnet\tools\.store\dotnet-sos\9.0.607501\dotnet-sos\9.0.607501\tools\net6.0\any\win-x64
Copying files from C:\Users\testusr\.dotnet\tools\.store\dotnet-sos\9.0.607501\dotnet-sos\9.0.607501\tools\net6.0\any\lib
Execute '.load C:\Users\testusr\.dotnet\sos\sos.dll' to load SOS in your Windows debugger.
SOS install succeeded

메시지에 따라 WinDbg에서 다음의 명령어를 내리면 됩니다.

.load C:\Users\testusr\.dotnet\sos\sos.dll

// 또는 환경 변수를 이용

as /e MyEnvVar USERPROFILE
.load ${MyEnvVar}\.dotnet\sos\sos.dll




그건 그렇고, .chain 명령어를 보면 CLRComposition 확장이 눈에 띕니다. ^^

0:000> .extmatch /D /e CLRComposition *
!CLRComposition.clrflush
!CLRComposition.disableclrcomposition
!CLRComposition.enableclrcomposition
!CLRComposition.enableclrplugin
!CLRComposition.forceclrmixedmodeunwind
!CLRComposition.tryunknownmodulesforclrbind

검색해 보면, 겨우 이 정도의 정보만 나오는데요,

// https://learn.microsoft.com/en-us/windows-hardware/drivers/debuggercmds/windbg-release-notes#improved-clr-debugging-experience-without-clrcompositiondll

The redistributable component dbgeng.dll now has improved stack walking support for CLR frames without the need for clrcomposition.dll to be present.


혹시 이에 대한 이력을 알고 계신 분은 덧글 부탁드립니다. ^^




[이 글에 대해서 여러분들과 의견을 공유하고 싶습니다. 틀리거나 미흡한 부분 또는 의문 사항이 있으시면 언제든 댓글 남겨주십시오.]







[최초 등록일: ]
[최종 수정일: 4/11/2025]

Creative Commons License
이 저작물은 크리에이티브 커먼즈 코리아 저작자표시-비영리-변경금지 2.0 대한민국 라이센스에 따라 이용하실 수 있습니다.
by SeongTae Jeong, mailto:techsharer at outlook.com

비밀번호

댓글 작성자
 




... 31  32  33  34  35  36  37  38  39  40  41  [42]  43  44  45  ...
NoWriterDateCnt.TitleFile(s)
12886정성태12/20/202114649스크립트: 37. 파이썬 - uwsgi의 --enable-threads 옵션 [2]
12885정성태12/20/202115673오류 유형: 776. uwsgi-plugin-python3 환경에서 MySQLdb 사용 환경
12884정성태12/20/202114591개발 환경 구성: 620. Windows 10+에서 WMI root/Microsoft/Windows/WindowsUpdate 네임스페이스 제거
12883정성태12/19/202115040오류 유형: 775. uwsgi-plugin-python3 환경에서 "ModuleNotFoundError: No module named 'django'" 오류 발생
12882정성태12/18/202114514개발 환경 구성: 619. Windows Server에서 WSL을 위한 리눅스 배포본을 설치하는 방법
12881정성태12/17/202114128개발 환경 구성: 618. WSL Ubuntu 20.04에서 파이썬을 위한 uwsgi 설치 방법 (2)
12880정성태12/16/202115115VS.NET IDE: 170. Visual Studio에서 .NET Core/5+ 역어셈블 소스코드 확인하는 방법
12879정성태12/16/202121641오류 유형: 774. Windows Server 2022 + docker desktop 설치 시 WSL 2로 선택한 경우 "Failed to deploy distro docker-desktop to ..." 오류 발생
12878정성태12/15/202115931개발 환경 구성: 617. 윈도우 WSL 환경에서 같은 종류의 리눅스를 다중으로 설치하는 방법
12877정성태12/15/202115241스크립트: 36. 파이썬 - pymysql 기본 예제 코드
12876정성태12/14/202115081개발 환경 구성: 616. Custom Sources를 이용한 Azure Monitor Metric 만들기
12875정성태12/13/202113972스크립트: 35. python - time.sleep(...) 호출 시 hang이 걸리는 듯한 문제
12874정성태12/13/202113825오류 유형: 773. shell script 실행 시 "$'\r': command not found" 오류
12873정성태12/12/202115208오류 유형: 772. 리눅스 - PATH에 등록했는데도 "command not found"가 나온다면?
12872정성태12/12/202115608개발 환경 구성: 615. GoLang과 Python 빌드가 모두 가능한 docker 이미지 만들기
12871정성태12/12/202114636오류 유형: 771. docker: Error response from daemon: OCI runtime create failed
12870정성태12/9/202113706개발 환경 구성: 614. 파이썬 - PyPI 패키지 만들기 (4) package_data 옵션
12869정성태12/8/202116407개발 환경 구성: 613. git clone 실행 시 fingerprint 묻는 단계를 생략하는 방법
12868정성태12/7/202114783오류 유형: 770. twine 업로드 시 "HTTPError: 400 Bad Request ..." 오류 [1]
12867정성태12/7/202114555개발 환경 구성: 612. 파이썬 - PyPI 패키지 만들기 (3) entry_points 옵션
12866정성태12/7/202121461오류 유형: 769. "docker build ..." 시 "failed to solve with frontend dockerfile.v0: failed to read dockerfile ..." 오류
12865정성태12/6/202114795개발 환경 구성: 611. 파이썬 - PyPI 패키지 만들기 (2) long_description, cmdclass 옵션
12864정성태12/6/202112477Linux: 46. WSL 환경에서 find 명령을 사용해 파일을 찾는 방법
12863정성태12/4/202114664개발 환경 구성: 610. 파이썬 - PyPI 패키지 만들기
12862정성태12/3/202112622오류 유형: 768. Golang - 빌드 시 "cmd/go: unsupported GOOS/GOARCH pair linux /amd64" 오류
12861정성태12/3/202116459개발 환경 구성: 609. 파이썬 - "Windows embeddable package"로 개발 환경 구성하는 방법 [1]
... 31  32  33  34  35  36  37  38  39  40  41  [42]  43  44  45  ...