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)
13137정성태10/8/202214132.NET Framework: 2055. 리눅스 환경의 .NET Core 3/5+ 메모리 덤프로부터 닷넷 모듈을 추출하는 방법
13136정성태10/7/202214491.NET Framework: 2054. .NET Core/5+ SDK 설치 없이 dotnet-dump 사용하는 방법
13135정성태10/5/202215007.NET Framework: 2053. 리눅스 환경의 .NET Core 3/5+ 메모리 덤프를 분석하는 방법 - 두 번째 이야기 [1]
13134정성태10/4/202212208오류 유형: 820. There is a problem with AMD Radeon RX 5600 XT device. For more information, search for 'graphics device driver error code 31'
13133정성태10/4/202213349Windows: 211. Windows - (commit이 아닌) reserved 메모리 사용량 확인 방법 [1]
13132정성태10/3/202213383스크립트: 42. 파이썬 - latexify-py 패키지 소개 - 함수를 mathjax 식으로 표현
13131정성태10/3/202217187.NET Framework: 2052. C# - Windows Forms의 데이터 바인딩 지원(DataBinding, DataSource) [2]파일 다운로드1
13130정성태9/28/202213002.NET Framework: 2051. .NET Core/5+ - 에러 로깅을 위한 Middleware가 동작하지 않는 경우파일 다운로드1
13129정성태9/27/202213619.NET Framework: 2050. .NET Core를 IIS에서 호스팅하는 경우 .NET Framework CLR이 함께 로드되는 환경
13128정성태9/23/202216550C/C++: 158. Visual C++ - IDL 구문 중 "unsigned long"을 인식하지 못하는 #import [1]파일 다운로드1
13127정성태9/22/202214810Windows: 210. WSL에 systemd 도입
13126정성태9/15/202215341.NET Framework: 2049. C# 11 - 정적 메서드에 대한 delegate 처리 시 cache 적용
13125정성태9/14/202215760.NET Framework: 2048. C# 11 - 구조체 필드의 자동 초기화(auto-default structs)
13124정성태9/13/202215520.NET Framework: 2047. Golang, Python, C#에서의 CRC32 사용
13123정성태9/8/202215569.NET Framework: 2046. C# 11 - 멤버(속성/필드)에 지정할 수 있는 required 예약어 추가
13122정성태8/26/202215995.NET Framework: 2045. C# 11 - 메서드 매개 변수에 대한 nameof 지원
13121정성태8/23/202212402C/C++: 157. Golang - 구조체의 slice 필드를 Reflection을 이용해 변경하는 방법
13120정성태8/19/202215983Windows: 209. Windows NT Service에서 UI를 다루는 방법 [3]
13119정성태8/18/202215132.NET Framework: 2044. .NET Core/5+ 프로젝트에서 참조 DLL이 보관된 공통 디렉터리를 지정하는 방법
13118정성태8/18/202212673.NET Framework: 2043. WPF Color의 기본 색 영역은 (sRGB가 아닌) scRGB [2]
13117정성태8/17/202216327.NET Framework: 2042. C# 11 - 파일 범위 내에서 유효한 타입 정의 (File-local types)파일 다운로드1
13116정성태8/4/202216774.NET Framework: 2041. C# - Socket.Close 시 Socket.Receive 메서드에서 예외가 발생하는 문제파일 다운로드1
13115정성태8/3/202217335.NET Framework: 2040. C# - ValueTask와 Task의 성능 비교 [1]파일 다운로드1
13114정성태8/2/202217219.NET Framework: 2039. C# - Task와 비교해 본 ValueTask 사용법파일 다운로드1
13113정성태7/31/202216698.NET Framework: 2038. C# 11 - Span 타입에 대한 패턴 매칭 (Pattern matching on ReadOnlySpan<char>)
13112정성태7/30/202217573.NET Framework: 2037. C# 11 - 목록 패턴(List patterns) [1]파일 다운로드1
... 31  [32]  33  34  35  36  37  38  39  40  41  42  43  44  45  ...