.NET Runtimeのイベントログ
このページでは、Windowsのイベントログに記録される 「.NET Runtime」ソースのイベントについて、代表的なイベントIDやその意味、主な発生原因を参考情報としてまとめています。公開ドキュメントがなく自分で調べてみた限りのものとなりますので、もしかすると他のイベントログもあるかもしれません。
イベントID1022(COR_Profiler)
プロファイラー関連のエラーが発生した時のイベントIDです。.NET Frameworkでのみ出力されます。実装は.NET Coreのアーカイブに残されています。
.NET Runtime自体の問題を示すものではなく、プロファイラーで問題が生じた場合もランタイムは基本的に無視して処理を進めるため、このログが記録されていてもアプリケーションの動作に影響が生じることは通常ありません。(参考情報: https://jpdscore.github.io/blog/dotnet/common-issues-caused-by-dotnet-profiler/)
イベントログのメッセージ例
.NET Runtime version 4.0.30319.0 - CoCreateInstance 中に、プロファイラーを読み込めませんでした。 プロファイラーの CLSID: '{909B2AD5-42DF-4832-8EA0-7808E80D7741}'。 HRESULT: 0x80040154。 プロセス ID (10 進数): 11140。 メッセージ ID: [0x2504]。
イベントログが記録される手順の例
- コマンドプロンプトを起動します。
- 以下のコマンドを実行します。
set COR_ENABLE_PROFILING=1
set COR_PROFILER={00000000-0000-0000-0000-000000000000}
powershell.exe
この例では、プロファイル機能を有効にして無効なプロファイラーのCLSIDを指定した状態で.NET Frameworkアプリケーションを起動しています。
イベントログ出力処理のスタック例
0:000> knL
# Child-SP RetAddr Call Site
00 000000af`f0ece6b8 00007ffc`20754b59 ADVAPI32!ReportEventW
01 000000af`f0ece6c0 00007ffc`2050eac6 clr!ClrReportEvent+0x7d
02 (Inline Function) --------`-------- clr!ClrReportEvent+0x21
03 000000af`f0ece720 00007ffc`205b9989 clr!ReportEventCLR+0xee
04 000000af`f0ece7c0 00007ffc`205b98b0 clr!ProfilingAPIUtility::LogProfEventVA+0xd1
05 000000af`f0ecec70 00007ffc`205ed8bb clr!ProfilingAPIUtility::LogProfError+0x24
06 000000af`f0ececa0 00007ffc`205edccd clr!CoCreateProfiler+0xcf
07 000000af`f0eced20 00007ffc`205f04b4 clr!EEToProfInterfaceImpl::CreateProfiler+0xa9
08 000000af`f0ecedd0 00007ffc`205b940c clr!EEToProfInterfaceImpl::Init+0x23c
09 000000af`f0eceee0 00007ffc`204e9697 clr!ProfilingAPIUtility::LoadProfiler+0x348
0a 000000af`f0ecefd0 00007ffc`202cba00 clr!ProfilingAPIUtility::AttemptLoadProfilerForStartup+0x21dc8f
0b 000000af`f0ecf070 00007ffc`2023c92d clr!ProfilingAPIUtility::InitializeProfiling+0x3c
0c 000000af`f0ecf0a0 00007ffc`202cdd2d clr!EEStartupHelper+0x605
0d 000000af`f0ecf2c0 00007ffc`2016f829 clr!EEStartup+0x15
0e 000000af`f0ecf310 00007ffc`2051e0c3 clr!EnsureEEStarted+0x115
0f 000000af`f0ecf370 00007ffc`2051e030 clr!CorRuntimeHostBase::Start+0x57
10 000000af`f0ecf3b0 00007ff6`19fb46d8 clr!CorHost::Start+0x50
11 (Inline Function) --------`-------- powershell!NativeMsh::PwrshCommon::LaunchCLR+0x91
12 000000af`f0ecf3f0 00007ff6`19fb1dcc powershell!LaunchManagedMonad+0x2f4
13 000000af`f0ecfa00 00007ff6`19fb51e4 powershell!wmain+0x9bc
14 000000af`f0ecfbd0 00007ffc`406fe8d7 powershell!__wmainCRTStartup+0x144
15 000000af`f0ecfc10 00007ffc`419bbf2c KERNEL32!BaseThreadInitThunk+0x17
16 000000af`f0ecfc40 00000000`00000000 ntdll!RtlUserThreadStart+0x2c
イベントID1023(ERT_UnmanagedFailFast)
共通言語ランタイムのネイティブコード部分で、実行を継続できないような致命的エラーが発生した場合に記録されます。
イベントログのメッセージ例(.NET Framework)
アプリケーション:ConsoleApp2.exe
フレームワークのバージョン:v4.0.30319
説明: .NET ランタイムの内部エラーのため、プロセスが中止されました IP 73B18B9D (73AF0000)、終了コード 80131506。
イベントログのメッセージ例(.NET)
Application: ConsoleApp2.exe
CoreCLR Version: 8.0.1224.60305
.NET Version: 8.0.12
Description: The process was terminated due to an internal error in the .NET Runtime at IP 0x69FA5E57 (0x69EA0000) with exit code 0x80131506.
イベントID1023が記録されるコードの例
// Reference: https://jpdscore.github.io/blog/dotnet/feee-managed-heap-corruption/
// Build configuration Release|x86 with /unsafe
using System.Runtime.InteropServices;
namespace ConsoleApp2
{
internal class Program
{
[StructLayout(LayoutKind.Sequential)]
internal unsafe struct ObjectHeader_Array
{
public IntPtr Methodtable;
public UInt32 Length;
}
static void Main(string[] args)
{
unsafe
{
byte[] buffer = new byte[] { 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11 };
fixed (byte* ptr = buffer)
{
ObjectHeader_Array* pObject = (ObjectHeader_Array*)(ptr - sizeof(ObjectHeader_Array));
Console.WriteLine($"MethodTable: {pObject->Methodtable:X}");
Console.WriteLine($"Length: {pObject->Length}");
pObject->Length = 0x12345678; // corrupts array length...
}
}
GC.Collect();
}
}
}
イベントログ出力処理のスタック例
0:000> k
# ChildEBP RetAddr
00 02b7cf5c 6a14db8d ADVAPI32!ReportEventW
01 02b7cf5c 6a112826 coreclr!ClrReportEvent+0x37 [\src\coreclr\utilcode\safewrap.cpp @ 59]
02 (Inline) -------- coreclr!ClrReportEvent+0x12 [\src\coreclr\utilcode\safewrap.cpp @ 91]
03 02b7cf90 6a0bb794 coreclr!EventReporter::Report+0x8b [\src\coreclr\vm\eventreporter.cpp @ 421]
04 02b7db38 6a0baedc coreclr!EEPolicy::LogFatalError+0x3b2 [\src\coreclr\vm\eepolicy.cpp @ 485]
05 02b7dea0 6a046c52 coreclr!EEPolicy::HandleFatalError+0x117 [\src\coreclr\vm\eepolicy.cpp @ 810]
06 02b7ded4 69f4e356 coreclr!CLRVectoredExceptionHandlerPhase3+0xf8886 [\src\coreclr\vm\excep.cpp @ 7132]
07 02b7defc 69f4e330 coreclr!CLRVectoredExceptionHandlerPhase2+0x20 [\src\coreclr\vm\excep.cpp @ 6860]
08 02b7df24 69f4e233 coreclr!CLRVectoredExceptionHandler+0x98 [\src\coreclr\vm\excep.cpp @ 6827]
09 02b7df74 77182f2f coreclr!CLRVectoredExceptionHandlerShim+0x123 [\src\coreclr\vm\excep.cpp @ 7494]
0a 02b7dfc4 7717e424 ntdll!RtlpCallVectoredHandlers+0xf8
0b (Inline) -------- ntdll!RtlCallVectoredExceptionHandlers+0xa
0c 02b7e05c 7718babf ntdll!RtlDispatchException+0x67
0d 02b7ebb8 69fa5e57 ntdll!KiUserExceptionDispatcher+0xf
0e (Inline) -------- coreclr!WKS::gc_heap::set_brick+0x19 [\src\coreclr\gc\gc.cpp @ 8694]
0f 02b7ebb8 69f70cfe coreclr!WKS::gc_heap::update_brick_table+0x86 [\src\coreclr\gc\gc.cpp @ 30106]
10 02b7ed80 69f6f9bb coreclr!WKS::gc_heap::plan_phase+0xc0e [\src\coreclr\gc\gc.cpp @ 32498]
11 02b7edb8 69f6e535 coreclr!WKS::gc_heap::gc1+0x81 [\src\coreclr\gc\gc.cpp @ 22335]
12 (Inline) -------- coreclr!GCToOSInterface::GetLowPrecisionTimeStamp+0x5 [\src\coreclr\gc\windows\gcenv.windows.cpp @ 1091]
13 02b7edd0 69f480c9 coreclr!WKS::gc_heap::garbage_collect+0x160 [\src\coreclr\gc\gc.cpp @ 24340]
14 02b7edfc 6a14102d coreclr!WKS::GCHeap::GarbageCollectGeneration+0xf4 [\src\coreclr\gc\gc.cpp @ 50537]
15 02b7ee0c 6a140f93 coreclr!WKS::GCHeap::GarbageCollectTry+0x59 [\src\coreclr\gc\gc.cpp @ 49760]
16 02b7ee3c 6a0b70e6 coreclr!WKS::GCHeap::GarbageCollect+0xc3 [\src\coreclr\gc\gc.cpp @ 49692]
17 02b7ee84 69473162 coreclr!GCInterface_Collect+0x56 [\src\coreclr\vm\comutilnative.cpp @ 895]
18 02b7eecc 05a335f7 System_Private_CoreLib!System.GC.Collect+0x22 [/_/src/coreclr/System.Private.CoreLib/src/System/GC.CoreCLR.cs @ 180]
19 02b7ef0c 69fb83f9 ConsoleApp2_exe!ConsoleApp2.Program.Main+0x127
...
イベントID1024
Windowsサービスなどの非対話型プロセスとして実行されている.NET Frameworkアプリケーションで、共通言語ランタイムの初期化を完了する前に致命的なエラーが発生した場合に記録されます。アプリケーションの実行可能ファイル(exeファイル)が破損している場合や、ウィルス対策ソフトウェアの介入の影響などで発生することがあります。
対話型プロセスの場合は以下のようなメッセージボックスが表示されます。
.NETや.NET Coreでは出力されることはなくなっていますが、実装はアーカイブに残されています。
イベントログのメッセージ例
.NET Runtime version : 4.0.30319.0 - 致命的なエラーCLR エラー: 8007000b.
プログラムを終了します。
残念ながらアプリケーション名はイベントログに出力されませんので、イベントログから出力元となったアプリケーションを直接特定することはできません。プロセスIDはイベントログのプロパティから確認できるため、プロセス起動の監査ログなど他の情報と照らし合わせて出力したアプリケーションを特定する必要があります。
イベントログが記録される手順の例
- Visual Studioに付属する開発者プロンプトを起動します。
editbin.exe /stack:0x100000,0x100000 <実行可能ファイル名>
を実行して.NET Frameworkアプリケーションの既定のスタックサイズを変更します。- アプリケーションを実行します。
メッセージボックス表示処理のスタック例
0:000> knL
# ChildEBP RetAddr
01 0096e350 73b741c8 USER32!MessageBoxW+0x45
02 0096e378 73f52769 clr!LateboundMessageBoxW+0x4a
03 0096ecb4 73f52c11 clr!MessageBoxImpl+0x4c2
04 0096f57c 73f528f2 clr!UtilMessageBoxNonLocalizedVA+0x331
05 0096f5a0 73f52800 clr!UtilMessageBoxNonLocalizedVA+0x1b
06 0096f624 73f52e54 clr!UtilMessageBoxVA+0x92
07 0096f64c 73e465cb clr!UtilMessageBoxCatastrophicVA+0x31
08 (Inline) -------- clr!EEMessageBoxCatastrophicVA+0x13
09 0096f660 73d659eb clr!EEMessageBoxCatastrophic+0x16
0a (Inline) -------- clr!BaseHolder::Release+0x5
0b (Inline) -------- clr!BaseHolder::{dtor}+0x5
0c 0096f6ac 73d58ed3 clr!VMDumpCOMErrors+0xee
0d 0096f6ec 73b7f23c clr!_CorExeMainInternal+0x12e
0e 0096f728 742da38e clr!_CorExeMain+0x4d
0f 0096f764 74cdfbae mscoreei!_CorExeMain+0x100
10 0096f774 74ce5788 MSCOREE!ShellShim__CorExeMain+0x9e
11 0096f78c 750b5d49 MSCOREE!_CorExeMain_Exported+0x8
12 0096f78c 7717cdeb KERNEL32!BaseThreadInitThunk+0x19
13 0096f7e4 7717cd71 ntdll!__RtlUserThreadStart+0x2b
14 0096f7f4 00000000 ntdll!_RtlUserThreadStart+0x1b
イベントログ出力処理のスタック例
# ChildEBP RetAddr
00 008fee9c 73f57404 advapi32!ReportEventW+0x35
01 (Inline) -------- clr!ClrReportEvent+0x38
02 008feed4 73f52b34 clr!ClrReportEvent+0x39
03 008ff7a0 73f528f2 clr!UtilMessageBoxNonLocalizedVA+0x248
04 008ff7c4 73f52800 clr!UtilMessageBoxNonLocalizedVA+0x1b
05 008ff848 73f52e54 clr!UtilMessageBoxVA+0x92
06 008ff870 73e465cb clr!UtilMessageBoxCatastrophicVA+0x31
07 (Inline) -------- clr!EEMessageBoxCatastrophicVA+0x13
08 008ff884 73d659eb clr!EEMessageBoxCatastrophic+0x16
09 (Inline) -------- clr!BaseHolder::Release+0x5
0a (Inline) -------- clr!BaseHolder::{dtor}+0x5
0b 008ff8d0 73d58ed3 clr!VMDumpCOMErrors+0xee
0c 008ff910 73b7f23c clr!_CorExeMainInternal+0x12e
0d 008ff94c 742da38e clr!_CorExeMain+0x4d
0e 008ff988 74cdfbae mscoreei!_CorExeMain+0x100
0f 008ff998 74ce5788 mscoree!ShellShim__CorExeMain+0x9e
10 008ff9b0 750b5d49 mscoree!_CorExeMain_Exported+0x8
11 008ff9b0 7717cdeb kernel32!BaseThreadInitThunk+0x19
12 008ffa08 7717cd71 ntdll!__RtlUserThreadStart+0x2b
13 008ffa18 00000000 ntdll!_RtlUserThreadStart+0x1b
イベントID1025(ERT_ManagedFailFast)
.NET Frameworkアプリケーションのマネージドコード内でSystem.Environment.FailFastメソッドが呼び出された場合に記録されます。
イベントログのメッセージ例(.NET Framework)
アプリケーション:ConsoleApp1.exe
フレームワークのバージョン:v4.0.30319
説明: アプリケーションは System.Environment.FailFast (文字列メッセージ) を使用してプロセスの終了を要求しました。
メッセージ:something happened.
スタック:
場所 System.Environment.FailFast(System.String)
場所 ConsoleApp28.Program.Main(System.String[])
イベントログのメッセージ例(.NET)
Application: ConsoleApp1.exe
CoreCLR Version: 8.0.1224.60305
.NET Version: 8.0.12
Description: The application requested process termination through System.Environment.FailFast.
Message: something happened.
Stack:
at System.Environment.FailFast(System.String)
at Program.<Main>$(System.String[])
イベントID1025が記録されるコードの例
static void Main(string[] args)
{
System.Environment.FailFast("something happened.");
}
イベントログ出力処理のスタック例
0:000> k
# Child-SP RetAddr Call Site
00 00000071`8857d4b8 00007ffb`08d8c471 ADVAPI32!ReportEventW
01 00000071`8857d4c0 00007ffb`08d2643f coreclr!ClrReportEvent+0x75 [\src\coreclr\utilcode\safewrap.cpp @ 59]
02 (Inline Function) --------`-------- coreclr!ClrReportEvent+0x17 [\src\coreclr\utilcode\safewrap.cpp @ 91]
03 00000071`8857d520 00007ffb`08cad8af coreclr!EventReporter::Report+0x97 [\src\coreclr\vm\eventreporter.cpp @ 421]
04 00000071`8857d580 00007ffb`08cacc6f coreclr!EEPolicy::LogFatalError+0x487 [\src\coreclr\vm\eepolicy.cpp @ 485]
05 00000071`8857e230 00007ffb`08ddf142 coreclr!EEPolicy::HandleFatalError+0x133 [\src\coreclr\vm\eepolicy.cpp @ 810]
06 00000071`8857e830 00007ffb`08ddec49 coreclr!SystemNative::GenericFailFast+0x2fe [\src\coreclr\classlibnative\bcltype\system.cpp @ 285]
07 00000071`8857eb00 00007ffa`a902365c coreclr!SystemNative::FailFast+0x89 [\src\coreclr\classlibnative\bcltype\system.cpp @ 304]
08 00000071`8857ec50 00007ffb`08bae143 ConsoleApp22!Program.<Main>$+0x2c
...
イベントID1026(ERT_UnhandledException)
.NET Frameworkアプリケーション内で未処理のCLR例外が発生した場合に記録されます。ログ出力の実装はこちらにあります。
イベントログのメッセージ例(.NET Framework)
アプリケーション:ConsoleApp1.exe
フレームワークのバージョン:v4.0.30319
説明: ハンドルされない例外のため、プロセスが中止されました。
例外情報:System.Exception
場所 ConsoleApp1.Program.Main(System.String[])
イベントログのメッセージ例(.NET)
Application: ConsoleApp1.exe
CoreCLR Version: 8.0.1224.60305
.NET Version: 8.0.12
Description: The process was terminated due to an unhandled exception.
Exception Info: System.Exception
at Program.<Main>$(String[] args) in C:\source\repos\ConsoleApp1\ConsoleApp1\Program.cs:line 3
イベントID1026が記録されるコードの例
static void Main(string[] args)
{
throw new Exception("something happened.");
}
イベントログ出力処理のスタック例
0:000> k
# Child-SP RetAddr Call Site
00 00000034`e157bee8 00007ffb`08c1c471 ADVAPI32!ReportEventW
01 00000034`e157bef0 00007ffb`08bb643f coreclr!ClrReportEvent+0x75 [\src\coreclr\utilcode\safewrap.cpp @ 59]
02 (Inline Function) --------`-------- coreclr!ClrReportEvent+0x17 [\src\coreclr\utilcode\safewrap.cpp @ 91]
03 00000034`e157bf50 00007ffb`08afaa28 coreclr!EventReporter::Report+0x97 [\src\coreclr\vm\eventreporter.cpp @ 421]
04 00000034`e157bfb0 00007ffb`08afa3c2 coreclr!DefaultCatchHandlerExceptionMessageWorker+0x224 [\src\coreclr\vm\excep.cpp @ 5123]
05 00000034`e157caf0 00007ffb`08afcd20 coreclr!DefaultCatchHandler+0x31e [\src\coreclr\vm\excep.cpp @ 5308]
06 00000034`e157cd60 00007ffb`08afc906 coreclr!InternalUnhandledExceptionFilter_Worker+0x3e0 [\src\coreclr\vm\excep.cpp @ 4846]
07 00000034`e157ce80 00007ffb`08c9d040 coreclr!InternalUnhandledExceptionFilter+0xe [\src\coreclr\vm\excep.cpp @ 4906]
08 00000034`e157ceb0 00007ffc`3f48bcc3 coreclr!COMUnhandledExceptionFilter+0x40 [\src\coreclr\vm\excep.cpp @ 5052]
09 00000034`e157cee0 00007ffc`41a68cba KERNELBASE!UnhandledExceptionFilter+0x1f3
0a (Inline Function) --------`-------- ntdll!RtlpThreadExceptionFilter+0x2e
0b 00000034`e157cfd0 00007ffc`41a23dd3 ntdll!RtlUserThreadStart$filt$0+0x3f
0c 00000034`e157d000 00007ffc`41a63f0f ntdll!__C_specific_handler+0x93
0d 00000034`e157d070 00007ffc`41913b78 ntdll!RtlpExecuteHandlerForException+0xf
0e 00000034`e157d0a0 00007ffc`41912b86 ntdll!RtlDispatchException+0x2c8
0f 00000034`e157d7f0 00007ffc`3f43bb0a ntdll!RtlRaiseException+0x206
10 00000034`e157e660 00007ffb`08991bb6 KERNELBASE!RaiseException+0x8a
11 00000034`e157e760 00007ffb`08991679 coreclr!RaiseTheExceptionInternalOnly+0x262 [\src\coreclr\vm\excep.cpp @ 2795]
12 00000034`e157e880 00007ffa`a8ee3827 coreclr!IL_Throw+0xb9 [\src\coreclr\vm\jithelpers.cpp @ 4247]
13 00000034`e157e9e0 00007ffb`08a3e143 ConsoleApp22_exe!Program.<Main>$+0x87
...
イベントID1031(Standalone GC load failure)
アプリケーションでスタンドアロンGCのロードに失敗したときに出力されるイベントIDです。.NET Frameworkでのみ出力されます。
イベントログが記録される手順の例
set COMPlus_GCName=test.dll
powershell.exe
イベントログのメッセージ例
.NET Runtime version 4.0.30319.0 - Load of local GC library test.dll failed
イベントログ出力処理のスタック例
0:000> knL
# Child-SP RetAddr Call Site
00 00000096`ecd2eaa8 00007ffc`20754b59 ADVAPI32!ReportEventW
01 00000096`ecd2eab0 00007ffc`2050eac6 clr!ClrReportEvent+0x7d
02 (Inline Function) --------`-------- clr!ClrReportEvent+0x21
03 00000096`ecd2eb10 00007ffc`205727d0 clr!ReportEventCLR+0xee
04 00000096`ecd2ebb0 00007ffc`20572543 clr!`anonymous namespace'::LogGCLoadError+0x128
05 00000096`ecd2efb0 00007ffc`204c0db0 clr!`anonymous namespace'::LoadAndInitializeGC+0x5f
06 (Inline Function) --------`-------- clr!GCHeapUtilities::LoadAndInitialize+0x24a95e
07 00000096`ecd2f240 00007ffc`2023c7da clr!InitializeGarbageCollector+0x24a988
08 00000096`ecd2f270 00007ffc`202cdd2d clr!EEStartupHelper+0x4b2
09 00000096`ecd2f490 00007ffc`2016f829 clr!EEStartup+0x15
0a 00000096`ecd2f4e0 00007ffc`2051e0c3 clr!EnsureEEStarted+0x115
0b 00000096`ecd2f540 00007ffc`2051e030 clr!CorRuntimeHostBase::Start+0x57
0c 00000096`ecd2f580 00007ff6`19fb46d8 clr!CorHost::Start+0x50
0d (Inline Function) --------`-------- powershell!NativeMsh::PwrshCommon::LaunchCLR+0x91
0e 00000096`ecd2f5c0 00007ff6`19fb1dcc powershell!LaunchManagedMonad+0x2f4
0f 00000096`ecd2fbd0 00007ff6`19fb51e4 powershell!wmain+0x9bc
10 00000096`ecd2fda0 00007ffc`406fe8d7 powershell!__wmainCRTStartup+0x144
11 00000096`ecd2fde0 00007ffc`419bbf2c KERNEL32!BaseThreadInitThunk+0x17
12 00000096`ecd2fe10 00000000`00000000 ntdll!RtlUserThreadStart+0x2c