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

WinDbg 분석 사례 - IISreset 시점에 w3wp.exe의 crash 발생

이번 사례는 매우 쉽게 해결된 것으로 Full Memory Dump 분석을 너무 어려운 대상이라고 생각하는 분들을 위해서 올려봅니다. ^^




이상하게도, 웹 애플리케이션이 평소에는 아무런 문제가 없는데 iisreset을 하는 시점만 되면 꼭 비정상 종료가 발생합니다. 다행히 테스트 서버에서 발생한 현상이라 원격 디버깅 도구를 연결해 봤는데요, 웬일인지 (iisreset의 영향 때문인 듯) 원인 파악을 위한 단계까지 못 들어가고 그전에 디버깅 세션이 종료해 버립니다.

어쩔 수 없군요, 그렇다면 덤프가 나서야 합니다. ^^

// 참고: 시작하자마자 비정상 종료하는 프로세스의 메모리 덤프 - procdump
// 관리자 권한으로 실행

C:\temp> procdump -ma -i c:\temp

이후 iisreset을 하면 덤프가 생성되고, Debug Analysis에 맡겨 자동 분석했더니 이런 결과가 나왔습니다.

...[생략]...
Analysis Summary
 Error
Description	Recommendation
In w3wp.exe_...103043.dmp the assembly instruction at coreclr!ProcessCLRException+101a13 in C:\TestWebApp\coreclr.dll from Microsoft Corporation has caused an access violation exception (0xC0000005) when trying to read from memory location 0x00000000 on thread 22
Please follow up with the vendor Microsoft Corporation for C:\TestWebApp\coreclr.dll
 Notification
Description	Recommendation
DebugDiag determined that this dump file (w3wp.exe_...103043.dmp) is a crash dump and did not perform any hang analysis.	To run both hang rules and crash rules on crash dumps, select the following option in the 'Preferences' tab of the 'Settings' page in DebugDiag.Analysis.exe:

    'For crash dumps, run hang rules and crash rules'
Analysis Details
CrashHangAnalysis
Report for w3wp.exe_...103043.dmp
Type of Analysis Performed	Crash Analysis
Machine Name	WIN2019
Operating System	Windows Server - 17763
Number Of Processors	4
Process ID	2320
Process Image	c:\Windows\System32\inetsrv\w3wp.exe
Command Line	c:\windows\system32\inetsrv\w3wp.exe -ap "TestWebApp" -v "v4.0" -l "webengine4.dll" -a \\.\pipe\iisipm24f866b3-407d-42cc-a459-31564ff6c55a -h "C:\inetpub\temp\apppools\TestWebApp\TestWebApp.config" -w "" -m 0 -t 20 -ta 0
System Up-Time	02:08:35
Process Up-Time	00:03:46
Processor Type	X64
Process Bitness	64-Bit
Faulting Thread
Entry point	  coreclr!Thread::intermediateThreadProc
Create time	  2025-06-29 오전 10:27:01
Time spent in user mode	  0 Days 0:0:0.250
Time spent in kernel mode	  0 Days 0:0:0.15



.NET Call Stack

TestWebApp.MyClass.GetWindowInfo(Int32)+be
[[InlinedCallFrame] (TestWebApp.MyClass.GetInfo)] TestWebApp.MyClass.GetInfo(Int32)
TestWebApp.ThreadProc.Run(System.Object)+261
System.Threading.ThreadHelper.ThreadStart_Context(System.Object)+c1
System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)+fffffffffed32eb4
System.Threading.ThreadHelper.ThreadStart(System.Object)+5e
[[GCFrame]]
[[DebuggerU2MCatchHandlerFrame]]

Full Call Stack

    Arg 1	    Arg 2	    Arg 3	    Arg 4	  Source
coreclr!EEPolicy::HandleFatalError+8b [f:\workspace\_work\1\s\src\vm\eepolicy.cpp @ 1177]	    0000000`00000000	    0000000`00000000	    0000000`00000000	    00002d2`b1a73ab0	  f:\workspace\_work\1\s\src\vm\eepolicy.cpp @ 1177
coreclr!ProcessCLRException+101a2e [f:\workspace\_work\1\s\src\vm\exceptionhandling.cpp @ 1043 + 30]	    00000eb`4f28e970	    00000eb`4f28ebc0	    00053d0`00000000	    00000eb`4f28e300	  f:\workspace\_work\1\s\src\vm\exceptionhandling.cpp @ 1043 + 30
ntdll!RtlpExecuteHandlerForException+f	    00000eb`4f28e290	    0000000`00000000	    0007ff8`4ce960ac	    0007ff8`4cae0000	  
ntdll!RtlDispatchException+40f	    0000000`00000000	    0000000`00000104	    0000000`00000001	    0007ff8`39aaa3d9	  
ntdll!KiUserExceptionDispatch+2e	    0000000`00000025	    0000000`00000000	    00000eb`4f28ebd0	    0007ff7`db81f9e7	  
TestWebApp.MyClass.GetWindowInfo(Int32)+be	    0000000`00000001	    00002ce`660985b0	    0007ff7`db4d1a8e	    00048cd`4aa75421	  
TestWebApp.MyClass.GetInfo()+21	    0000000`00000000	    0000000`00000000	    0000000`00000000	    0000000`00000000	  
TestWebApp.ThreadProc.Run(System.Object)+261	    0000000`00000000	    0000000`00000000	    0000000`00000000	    0000000`00000000	  
System.Threading.ThreadHelper.ThreadStart_Context(System.Object)+c1	    0000000`00000000	    0000000`00000000	    0000000`00000000	    0000000`00000000	  
System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)+fffffffffed32eb4	    0000000`00000000	    0000000`00000000	    0000000`00000000	    0000000`00000000	  
System.Threading.ThreadHelper.ThreadStart(System.Object)+5e	    0000000`00000000	    0000000`00000000	    0000000`00000000	    0000000`00000000	  



CLR Information
There are multiple CLR Runtimes loaded in this process:

CLR version = 4.700.20.6603 (this runtime was selected for analysis)
CLR version = 4.8.4785.0
Microsoft.Diagnostics.Runtime version = 0.9.2.0
Exception Information
CORECLR!PROCESSCLREXCEPTION+101A13In w3wp.exe_...103043.dmp the assembly instruction at coreclr!ProcessCLRException+101a13 in C:\TestWebApp\coreclr.dll from Microsoft Corporation has caused an access violation exception (0xC0000005) when trying to read from memory location 0x00000000 on thread 22


Module Information
Image Name:	C:\TestWebApp\coreclr.dll	  Symbol Type:	PDB
Base address:	0x00000003`00905a4d	  Time Stamp:	Fri Jan 17 11:44:10 2020
Checksum:	0x00000000`00000000	  Comments:	Flavor=Retail
COM DLL:	False	  Company Name:	Microsoft Corporation
ISAPIExtension:	False	  File Description:	Microsoft .NET Runtime
ISAPIFilter:	False	  File Version:	4,700,20,6603 @Commit: 259ce7d4619478cfefe7b0c0f6fa765f765f7e37
Managed DLL:	False	  Internal Name:	CoreCLR.dll
VB DLL:	False	  Legal Copyright:	
Loaded Image Name:	coreclr.dll	  Legal Trademarks:	
Mapped Image Name:		  Original filename:	CoreCLR.dll
Module name:	coreclr	  Private Build:	
Single Threaded:	False	  Product Name:	
Module Size:	5.41 MBytes	  Product Version:	4,700,20,6603 @Commit: 259ce7d4619478cfefe7b0c0f6fa765f765f7e37
Symbol File Name:	e:\symbols\coreclr.pdb\60646608BDB040698AF8C9430E7E480E1\coreclr.pdb	  Special Build:	&


Analysis Rule Summary
Rule Name	Status	Details
CrashHangAnalysis - v (2.3.2.11)	Completed	 
	
Table of Contents
CrashHangAnalysis
Report for w3wp.exe_...103043.dmp
Faulting Thread

오호~~~ 아주 정확하게 원인이 나왔군요, ^^ 자신이 만든 어떤 메서드에서 오류가 발생했다는 것과 재현이 가능하다는 사실에 기반해 어느 부분에서 문제가 발생했는지 유추할 수 있을 것입니다.




회사에서 개발한 제품이 고객사에 설치돼 문제가 발생하는 경우, 대개 원격으로 접속하거나 출장 가야 하는 수밖에 없습니다. (그나마 코로나 시기를 지나면서 원격을 열어주는 고객사가 많아져서 좋군요. ^^) 그런데 문제는, 출장이든 원격이든 결국 문제는 고객사 측의 서버에서 발생한 경우이고, 운이 나쁘다면 테스트 서버가 아닌 실제 운영 서버에서 발생한 경우도 있다는 점입니다. 그런 상황에서 업무 서버에 Visual Studio를 설치하고 디버깅을 하는 것은 현실적으로 불가능하고, 대안으로 Remote Tools를 설치해 원격 디버깅을 고려할 수도 있지만 이것도 쉽지 않을 수 있습니다.

바로 그럴 때 "Full Memory Dump"가 해결책이 될 수 있습니다. 즉, 전반적인 환경과 문제점만 파악하고 메모리 덤프만 확보한 후 나오는 것입니다. 그 후, (고객사에서는 부릴 수 없었던) 여유를 가지고 느긋하게 자신의 익숙한 PC에서 덤프를 분석하면 되는 것입니다.

실제로 최근 사례의 경우, 캄보디아에서 제니퍼가 설치됐는데 모니터링이 동작하지 않는다는 이슈가 올라온 적이 있었는데요, 금융 업무라서 원격도 열어주지 못하는 상황이었습니다. 하지만 다행히 메모리 덤프는 가능하다고 해 파일 전송으로 받아 제 자리에서 분석 후 패치를 했었습니다. 만약, 메모리 덤프가 없었다면... 아마도 캄보디아까지 직접 가야만 했을 지도 모를 일입니다. ^^;




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







[최초 등록일: ]
[최종 수정일: 7/5/2025]

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

비밀번호

댓글 작성자
 




... 16  17  18  19  20  21  22  23  24  25  [26]  27  28  29  30  ...
NoWriterDateCnt.TitleFile(s)
13331정성태4/27/202311899오류 유형: 856. dockerfile - 구 버전의 .NET Core 이미지 사용 시 apt update 오류
13330정성태4/26/202313451Windows: 247. Win32 C/C++ - CS_GLOBALCLASS 설명
13329정성태4/24/202313505Windows: 246. Win32 C/C++ - 직접 띄운 대화창 템플릿을 위한 Modal 메시지 루프 생성파일 다운로드1
13328정성태4/19/202313195VS.NET IDE: 184. Visual Studio - Fine Code Coverage에서 동작하지 않는 Fake/Shim 테스트
13327정성태4/19/202313597VS.NET IDE: 183. C# - .NET Core/5+ 환경에서 Fakes를 이용한 단위 테스트 방법
13326정성태4/18/202316551.NET Framework: 2109. C# - 닷넷 응용 프로그램에서 SQLite 사용 (System.Data.SQLite) [1]파일 다운로드1
13325정성태4/18/202314013스크립트: 48. 파이썬 - PostgreSQL의 with 문을 사용한 경우 연결 개체 누수
13324정성태4/17/202314777.NET Framework: 2108. C# - Octave의 "save -binary ..."로 생성한 바이너리 파일 분석파일 다운로드1
13323정성태4/16/202314239개발 환경 구성: 677. Octave에서 Excel read/write를 위한 io 패키지 설치
13322정성태4/15/202315924VS.NET IDE: 182. Visual Studio - 32비트로만 빌드된 ActiveX와 작업해야 한다면?
13321정성태4/14/202313743개발 환경 구성: 676. WSL/Linux Octave - Python 스크립트 연동
13320정성태4/13/202313462개발 환경 구성: 675. Windows Octave 8.1.0 - Python 스크립트 연동
13319정성태4/12/202314283개발 환경 구성: 674. WSL 2 환경에서 GNU Octave 설치
13318정성태4/11/202313842개발 환경 구성: 673. JetBrains IDE에서 "Squash Commits..." 메뉴가 비활성화된 경우
13317정성태4/11/202314499오류 유형: 855. WSL 2 Ubuntu 20.04 - error: cannot communicate with server: Post http://localhost/v2/snaps/...
13316정성태4/10/202311600오류 유형: 854. docker-compose 시 "json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)" 오류 발생
13315정성태4/10/202313560Windows: 245. Win32 - 시간 만료를 갖는 컨텍스트 메뉴와 윈도우 메시지의 영역별 정의파일 다운로드1
13314정성태4/9/202314411개발 환경 구성: 672. DosBox를 이용한 Turbo C, Windows 3.1 설치 [1]
13313정성태4/9/202314067개발 환경 구성: 671. Hyper-V VM에 Turbo C 2.0 설치 [2]
13312정성태4/8/202313144Windows: 244. Win32 - 시간 만료를 갖는 MessageBox 대화창 구현 (개선된 버전)파일 다운로드1
13311정성태4/7/202314812C/C++: 163. Visual Studio 2022 - DirectShow 예제 컴파일(WAV Dest)
13310정성태4/6/202313652C/C++: 162. Visual Studio - /NODEFAULTLIB 옵션 설정 후 수동으로 추가해야 할 library
13309정성태4/5/202314780.NET Framework: 2107. .NET 6+ FileStream의 구조 변화
13308정성태4/4/202314743스크립트: 47. 파이썬의 time.time() 실숫값을 GoLang / C#에서 사용하는 방법 [1]
13307정성태4/4/202313266.NET Framework: 2106. C# - .NET Core/5+ 환경의 Windows Forms 응용 프로그램에서 HINSTANCE 구하는 방법
13306정성태4/3/202313492Windows: 243. Win32 - 윈도우(cbWndExtra) 및 윈도우 클래스(cbClsExtra) 저장소 사용 방법
... 16  17  18  19  20  21  22  23  24  25  [26]  27  28  29  30  ...