Skip to content

Deadlock between EventListenerLock and ArrayPoolEventSource static ctor #119014

@mdh1418

Description

@mdh1418

Description

Starting dotnet-counters during .NET app initialization can lead to a deadlock between the EventListenersLock and the ListLock acquired during ArrayPoolEventSource's static constructor.

Thread 0 acquires the EventListenersLock and waits for the ArrayPoolEventSource ListLock
Thread 8 acquires the ArrayPoolEventSource ListLock and waits for the EventListenerLock

0:000> ~*k

.  0  Id: 84c8.fd14 Suspend: 0 Teb: 00000066`91771000 Unfrozen
 # Child-SP          RetAddr               Call Site
00 00000066`919788e8 00007ffc`bdeb993f     ntdll!NtWaitForAlertByThreadId+0x14
01 00000066`919788f0 00007ffc`bdefaa3f     ntdll!RtlpWaitOnCriticalSection+0x58f
02 00000066`919789f0 00007ffc`bdefa1b2     ntdll!RtlpEnterCriticalSectionContended+0x1ef
03 00000066`91978a70 00007ffb`4c55b6db     ntdll!RtlEnterCriticalSection+0xf2
04 00000066`91978ab0 00007ffb`4bc3d29f     coreclr!minipal_mutex_enter+0x3b [Q:\source\mdh1418\runtime\src\native\minipal\mutex.c @ 50] 
05 00000066`91978ae0 00007ffb`4bbfe993     coreclr!CrstBase::Enter+0x1ef [Q:\source\mdh1418\runtime\src\coreclr\vm\crst.cpp @ 262] 
06 00000066`91978b50 00007ffb`4bbfdde9     coreclr!ListLockEntryBase<void *>::FinishDeadlockAwareEnter+0x43 [Q:\source\mdh1418\runtime\src\coreclr\vm\listlock.h @ 202] 
07 00000066`91978ba0 00007ffb`4bdd63c8     coreclr!ListLockEntryBase<void *>::LockHolder::DeadlockAwareAcquire+0x49 [Q:\source\mdh1418\runtime\src\coreclr\vm\listlock.h @ 228] 
08 00000066`91978bd0 00007ffb`4bdcf79f     coreclr!MethodTable::DoRunClassInitThrowing+0x768 [Q:\source\mdh1418\runtime\src\coreclr\vm\methodtable.cpp @ 3708] 
09 00000066`91979b10 00007ffb`4be3f12d     coreclr!MethodTable::CheckRunClassInitThrowing+0x42f [Q:\source\mdh1418\runtime\src\coreclr\vm\methodtable.cpp @ 3852] 
0a 00000066`91979d40 00007ffb`4be4a59e     coreclr!DynamicHelperFixup+0x55d [Q:\source\mdh1418\runtime\src\coreclr\vm\prestub.cpp @ 3193] 
0b 00000066`9197a460 00007ffb`4c4e547a     coreclr!DynamicHelperWorker+0x26e [Q:\source\mdh1418\runtime\src\coreclr\vm\prestub.cpp @ 3504] 
0c 00000066`9197a7e0 00007ffb`45127372     coreclr!DelayLoad_Helper+0x7a [Q:\source\mdh1418\runtime\src\coreclr\vm\amd64\ExternalMethodFixupThunk.asm @ 59] 
0d 00000066`9197a8a0 00007ffb`45033528     System_Private_CoreLib!System.Buffers.SharedArrayPool<char>.Rent+0x22 [Q:\source\mdh1418\runtime\src\libraries\System.Private.CoreLib\src\System\Buffers\SharedArrayPool.cs @ 52] 
0e 00000066`9197a930 00007ffa`ed4978ad     System_Private_CoreLib!System.Runtime.CompilerServices.DefaultInterpolatedStringHandler..ctor+0x38 [Q:\source\mdh1418\runtime\src\libraries\System.Private.CoreLib\src\System\Runtime\CompilerServices\DefaultInterpolatedStringHandler.cs @ 58] 
0f 00000066`9197a970 00007ffa`ed491470     system_diagnostics_diagnosticsource!System.Diagnostics.Metrics.MetricsEventSource.CommandHandler.ParseSpecs+0xfd [Q:\source\mdh1418\runtime\src\libraries\System.Diagnostics.DiagnosticSource\src\System\Diagnostics\Metrics\MetricsEventSource.cs @ 721] 
10 00000066`9197aa90 00007ffa`ed490617     system_diagnostics_diagnosticsource!System.Diagnostics.Metrics.MetricsEventSource.CommandHandler.OnEventCommand+0xb50 [Q:\source\mdh1418\runtime\src\libraries\System.Diagnostics.DiagnosticSource\src\System\Diagnostics\Metrics\MetricsEventSource.cs @ 513] 
11 00000066`9197ad60 00007ffb`450d64db     system_diagnostics_diagnosticsource!System.Diagnostics.Metrics.MetricsEventSource.OnEventCommand+0xb7 [Q:\source\mdh1418\runtime\src\libraries\System.Diagnostics.DiagnosticSource\src\System\Diagnostics\Metrics\MetricsEventSource.cs @ 329] 
12 00000066`9197adc0 00007ffb`450d4120     System_Private_CoreLib!System.Diagnostics.Tracing.EventSource.DoCommand+0x3db [Q:\source\mdh1418\runtime\src\libraries\System.Private.CoreLib\src\System\Diagnostics\Tracing\EventSource.cs @ 2792] 
13 00000066`9197ae60 00007ffb`450d28af     System_Private_CoreLib!System.Diagnostics.Tracing.EventSource.Initialize+0x2e0 [Q:\source\mdh1418\runtime\src\libraries\System.Private.CoreLib\src\System\Diagnostics\Tracing\EventSource.cs @ 1738] 
14 00000066`9197af10 00007ffb`450d27c2     System_Private_CoreLib!System.Diagnostics.Tracing.EventSource..ctor+0x9f
15 00000066`9197af70 00007ffa`ed48f408     System_Private_CoreLib!System.Diagnostics.Tracing.EventSource..ctor+0x12
16 00000066`9197afa0 00007ffa`ed48f3bd     system_diagnostics_diagnosticsource!System.Diagnostics.Metrics.MetricsEventSource..ctor+0x18
17 00000066`9197afd0 00007ffb`4c4e39d3     system_diagnostics_diagnosticsource!System.Diagnostics.Metrics.MetricsEventSource..cctor+0x2d
18 00000066`9197b010 00007ffb`4bf63710     coreclr!CallDescrWorkerInternal+0x83 [Q:\source\mdh1418\runtime\src\coreclr\vm\amd64\CallDescrWorkerAMD64.asm @ 74] 
19 00000066`9197b050 00007ffb`4bf64be6     coreclr!CallDescrWorkerWithHandler+0x130 [Q:\source\mdh1418\runtime\src\coreclr\vm\callhelpers.cpp @ 59] 
1a 00000066`9197b0b0 00007ffb`4bf643c6     coreclr!`DispatchCallDebuggerWrapper'::`3'::__Body::Run+0x66 [Q:\source\mdh1418\runtime\src\coreclr\vm\callhelpers.cpp @ 139] 
1b 00000066`9197b100 00007ffb`4bf64690     coreclr!DispatchCallDebuggerWrapper+0x76 [Q:\source\mdh1418\runtime\src\coreclr\vm\callhelpers.cpp @ 143] 
1c 00000066`9197b1a0 00007ffb`4bdf14e4     coreclr!DispatchCallSimple+0x250 [Q:\source\mdh1418\runtime\src\coreclr\vm\callhelpers.cpp @ 233] 
1d 00000066`9197b330 00007ffb`4bdd647f     coreclr!MethodTable::RunClassInitEx+0x5b4 [Q:\source\mdh1418\runtime\src\coreclr\vm\methodtable.cpp @ 3545] 
1e 00000066`9197b750 00007ffb`4bdcf79f     coreclr!MethodTable::DoRunClassInitThrowing+0x81f [Q:\source\mdh1418\runtime\src\coreclr\vm\methodtable.cpp @ 3727] 
1f 00000066`9197c690 00007ffb`4c0bb242     coreclr!MethodTable::CheckRunClassInitThrowing+0x42f [Q:\source\mdh1418\runtime\src\coreclr\vm\methodtable.cpp @ 3852] 
20 00000066`9197c8c0 00007ffb`4502f7df     coreclr!InitClassHelper+0x232 [Q:\source\mdh1418\runtime\src\coreclr\vm\jithelpers.cpp @ 257] 
21 00000066`9197cab0 00007ffb`450311f8     System_Private_CoreLib!System.Runtime.CompilerServices.InitHelpers.InitClassSlow+0x3f [Q:\source\mdh1418\runtime\src\coreclr\System.Private.CoreLib\src\System\Runtime\CompilerServices\InitHelpers.cs @ 20] 
22 00000066`9197cb80 00007ffb`4503123c     System_Private_CoreLib!System.Runtime.CompilerServices.StaticsHelpers.GetGCStaticBaseSlow+0x18 [Q:\source\mdh1418\runtime\src\coreclr\System.Private.CoreLib\src\System\Runtime\CompilerServices\StaticsHelpers.cs @ 57] 
23 00000066`9197cbc0 00007ffa`ed48f369     System_Private_CoreLib!System.Runtime.CompilerServices.StaticsHelpers.GetGCStaticBase+0x1c
24 00000066`9197cbf0 00007ffa`ed48f325     system_diagnostics_diagnosticsource!System.Diagnostics.Metrics.MetricsEventSource.GetInstance+0x19 [Q:\source\mdh1418\runtime\src\libraries\System.Diagnostics.DiagnosticSource\src\System\Diagnostics\Metrics\MetricsEventSource.cs @ 59] 
25 00000066`9197cc20 00007ffb`450db34c     System_Private_CoreLib!
26 00000066`9197cc60 00007ffb`450db0bc     System_Private_CoreLib!System.Diagnostics.Tracing.EventSourceInitHelper.GetMetricsEventSource+0xc [Q:\source\mdh1418\runtime\src\libraries\System.Private.CoreLib\src\System\Diagnostics\Tracing\EventSource.cs @ 3927] 
27 00000066`9197cc90 00007ffb`450cd0cc     System_Private_CoreLib!System.Diagnostics.Tracing.EventSource.OverrideEventProvider.OnControllerCommand+0x2c [Q:\source\mdh1418\runtime\src\libraries\System.Private.CoreLib\src\System\Diagnostics\Tracing\EventSource.cs @ 2496] 
28 00000066`9197cd20 00007ffb`450d1e50     System_Private_CoreLib!System.Diagnostics.Tracing.EventPipeEventProvider.HandleEnableNotification+0x8c
29 00000066`9197cd70 00007ffb`450cd1d5     System_Private_CoreLib!System.Diagnostics.Tracing.EventProviderImpl.ProviderCallback+0x90 [Q:\source\mdh1418\runtime\src\libraries\System.Private.CoreLib\src\System\Diagnostics\Tracing\EventProvider.cs @ 1283] 
2a 00000066`9197cde0 00007ffb`4b86a43a     System_Private_CoreLib!System.Diagnostics.Tracing.EventPipeEventProvider.Callback+0xf5 [Q:\source\mdh1418\runtime\src\libraries\System.Private.CoreLib\src\System\Diagnostics\Tracing\EventPipeEventProvider.cs @ 68] 
2b 00000066`9197ce80 00007ffb`4b879e05     coreclr!ep_rt_provider_invoke_callback+0xea [Q:\source\mdh1418\runtime\src\coreclr\vm\eventing\eventpipe\ep-rt-coreclr.h @ 492] 
2c 00000066`9197cfd0 00007ffb`4b860aeb     coreclr!provider_invoke_callback+0x385 [Q:\source\mdh1418\runtime\src\native\eventpipe\ep-provider.c @ 435] 
2d 00000066`9197d0f0 00007ffb`4b7f3f7b     coreclr!ep_create_provider+0x14b [Q:\source\mdh1418\runtime\src\native\eventpipe\ep.c @ 1347] 
2e 00000066`9197d1c0 00007ffb`4c01ef0b     coreclr!EventPipeAdapter::CreateProvider+0x1ab [Q:\source\mdh1418\runtime\src\coreclr\vm\eventpipeadapter.h @ 334] 
2f 00000066`9197d2f0 00007ffb`450cc3e2     coreclr!EventPipeInternal_CreateProvider+0x21b [Q:\source\mdh1418\runtime\src\coreclr\vm\eventpipeinternal.cpp @ 103] 
30 00000066`9197d4e0 00007ffb`450cd26a     System_Private_CoreLib!System.Diagnostics.Tracing.EventPipeInternal.CreateProvider+0x72 [Q:\source\mdh1418\runtime\artifacts\obj\coreclr\System.Private.CoreLib\windows.x64.Debug\generated\Microsoft.Interop.LibraryImportGenerator\Microsoft.Interop.LibraryImportGenerator\LibraryImports.g.cs @ 5793] 
31 00000066`9197d5c0 00007ffb`450cf8ca     System_Private_CoreLib!System.Diagnostics.Tracing.EventPipeEventProvider.Register+0x6a [Q:\source\mdh1418\runtime\src\libraries\System.Private.CoreLib\src\System\Diagnostics\Tracing\EventPipeEventProvider.cs @ 78] 
32 00000066`9197d600 00007ffb`450db4a7     System_Private_CoreLib!System.Diagnostics.Tracing.EventProvider.Register+0x3a
33 00000066`9197d640 00007ffb`450d92ec     System_Private_CoreLib!System.Diagnostics.Tracing.EventSourceInitHelper.PreregisterEventProviders+0x147 [Q:\source\mdh1418\runtime\src\libraries\System.Private.CoreLib\src\System\Diagnostics\Tracing\EventSource.cs @ 3969] 
34 00000066`9197d6d0 00007ffb`4c4e39d3     System_Private_CoreLib!System.Diagnostics.Tracing.EventSource.InitializeDefaultEventSources+0x9c
35 00000066`9197d740 00007ffb`4bf63710     coreclr!CallDescrWorkerInternal+0x83 [Q:\source\mdh1418\runtime\src\coreclr\vm\amd64\CallDescrWorkerAMD64.asm @ 74] 
36 00000066`9197d780 00007ffb`4bf642ab     coreclr!CallDescrWorkerWithHandler+0x130 [Q:\source\mdh1418\runtime\src\coreclr\vm\callhelpers.cpp @ 59] 
37 00000066`9197d7e0 00007ffb`4b84bcb4     coreclr!MethodDescCallSite::CallTargetWorker+0xb8b [Q:\source\mdh1418\runtime\src\coreclr\vm\callhelpers.cpp @ 546] 
38 00000066`9197dfd0 00007ffb`4bc390b2     coreclr!MethodDescCallSite::Call+0x24 [Q:\source\mdh1418\runtime\src\coreclr\vm\callhelpers.h @ 446] 
39 00000066`9197e000 00007ffb`4c51ec82     coreclr!CorHost2::CreateAppDomainWithManager+0x842 [Q:\source\mdh1418\runtime\src\coreclr\vm\corhost.cpp @ 669] 
3a 00000066`9197e6d0 00007ff7`e6c0e140     coreclr!coreclr_initialize+0x412 [Q:\source\mdh1418\runtime\src\coreclr\dlls\mscoree\exports.cpp @ 310] 
3b 00000066`9197e8d0 00007ff7`e6c133ca     corerun!run+0x1210 [Q:\source\mdh1418\runtime\src\coreclr\hosts\corerun\corerun.cpp @ 474] 
3c 00000066`9197f610 00007ff7`e6c1ff09     corerun!wmain+0x12a [Q:\source\mdh1418\runtime\src\coreclr\hosts\corerun\corerun.cpp @ 713] 
3d 00000066`9197f770 00007ff7`e6c1fe22     corerun!invoke_main+0x39 [D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl @ 91] 
3e 00000066`9197f7c0 00007ff7`e6c1fcde     corerun!__scrt_common_main_seh+0x132 [D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl @ 288] 
3f 00000066`9197f830 00007ff7`e6c1ff7e     corerun!__scrt_common_main+0xe [D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl @ 331] 
40 00000066`9197f860 00007ffc`bda7e8d7     corerun!wmainCRTStartup+0xe [D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_wmain.cpp @ 17] 
41 00000066`9197f890 00007ffc`bdebc34c     kernel32!BaseThreadInitThunk+0x17
42 00000066`9197f8c0 00000000`00000000     ntdll!RtlUserThreadStart+0x2c

   1  Id: 84c8.3f8 Suspend: 0 Teb: 00000066`91775000 Unfrozen
 # Child-SP          RetAddr               Call Site
00 00000066`91aff858 00007ffc`bdf1259e     ntdll!NtWaitForWorkViaWorkerFactory+0x14
01 00000066`91aff860 00007ffc`bda7e8d7     ntdll!TppWorkerThread+0x37e
02 00000066`91affbc0 00007ffc`bdebc34c     kernel32!BaseThreadInitThunk+0x17
03 00000066`91affbf0 00000000`00000000     ntdll!RtlUserThreadStart+0x2c

   2  Id: 84c8.9888 Suspend: 0 Teb: 00000066`91777000 Unfrozen
 # Child-SP          RetAddr               Call Site
00 00000066`91c7fa78 00007ffc`bdf1259e     ntdll!NtWaitForWorkViaWorkerFactory+0x14
01 00000066`91c7fa80 00007ffc`bda7e8d7     ntdll!TppWorkerThread+0x37e
02 00000066`91c7fde0 00007ffc`bdebc34c     kernel32!BaseThreadInitThunk+0x17
03 00000066`91c7fe10 00000000`00000000     ntdll!RtlUserThreadStart+0x2c

   3  Id: 84c8.c048 Suspend: 0 Teb: 00000066`91779000 Unfrozen
 # Child-SP          RetAddr               Call Site
00 00000066`91dff838 00007ffc`bdf1259e     ntdll!NtWaitForWorkViaWorkerFactory+0x14
01 00000066`91dff840 00007ffc`bda7e8d7     ntdll!TppWorkerThread+0x37e
02 00000066`91dffba0 00007ffc`bdebc34c     kernel32!BaseThreadInitThunk+0x17
03 00000066`91dffbd0 00000000`00000000     ntdll!RtlUserThreadStart+0x2c

   4  Id: 84c8.127e8 Suspend: 0 Teb: 00000066`9177b000 Unfrozen ".NET EventPipe"
 # Child-SP          RetAddr               Call Site
00 00000066`91f7f3d8 00007ffc`bb45df43     ntdll!NtWaitForMultipleObjects+0x14
01 00000066`91f7f3e0 00007ffc`bb45de11     KERNELBASE!WaitForMultipleObjectsEx+0x123
02 00000066`91f7f6d0 00007ffb`4b9fdf9e     KERNELBASE!WaitForMultipleObjects+0x11
03 00000066`91f7f710 00007ffb`4b857f78     coreclr!ds_ipc_poll+0x3be [Q:\source\mdh1418\runtime\src\native\eventpipe\ds-ipc-pal-namedpipe.c @ 263] 
04 00000066`91f7fa20 00007ffb`4b87ad8a     coreclr!ds_ipc_stream_factory_get_next_available_stream+0x298 [Q:\source\mdh1418\runtime\src\native\eventpipe\ds-ipc.c @ 393] 
05 00000066`91f7fbb0 00007ffb`4b87b0a4     coreclr!server_loop_tick+0x5a [Q:\source\mdh1418\runtime\src\native\eventpipe\ds-server.c @ 118] 
06 00000066`91f7fc50 00007ffc`bda7e8d7     coreclr!server_thread+0x94 [Q:\source\mdh1418\runtime\src\native\eventpipe\ds-server.c @ 185] 
07 00000066`91f7fc80 00007ffc`bdebc34c     kernel32!BaseThreadInitThunk+0x17
08 00000066`91f7fcb0 00000000`00000000     ntdll!RtlUserThreadStart+0x2c

   5  Id: 84c8.13b78 Suspend: 0 Teb: 00000066`9177d000 Unfrozen ".NET Debugger"
 # Child-SP          RetAddr               Call Site
00 00000066`920ff018 00007ffc`bb45df43     ntdll!NtWaitForMultipleObjects+0x14
01 00000066`920ff020 00007ffb`4b9ee29a     KERNELBASE!WaitForMultipleObjectsEx+0x123
02 00000066`920ff310 00007ffb`4b9f13a0     coreclr!DebuggerRCThread::MainLoop+0x81a [Q:\source\mdh1418\runtime\src\coreclr\debug\ee\rcthread.cpp @ 926] 
03 00000066`920ff7b0 00007ffb`4b9f14ee     coreclr!DebuggerRCThread::ThreadProc+0x890 [Q:\source\mdh1418\runtime\src\coreclr\debug\ee\rcthread.cpp @ 731] 
04 00000066`920ffb00 00007ffc`bda7e8d7     coreclr!DebuggerRCThread::ThreadProcStatic+0x9e [Q:\source\mdh1418\runtime\src\coreclr\debug\ee\rcthread.cpp @ 1322] 
05 00000066`920ffb40 00007ffc`bdebc34c     kernel32!BaseThreadInitThunk+0x17
06 00000066`920ffb70 00000000`00000000     ntdll!RtlUserThreadStart+0x2c

   6  Id: 84c8.11a5c Suspend: 0 Teb: 00000066`9177f000 Unfrozen ".NET Finalizer"
 # Child-SP          RetAddr               Call Site
00 00000066`9227ec48 00007ffc`bb45df43     ntdll!NtWaitForMultipleObjects+0x14
01 00000066`9227ec50 00007ffb`4c0263c4     KERNELBASE!WaitForMultipleObjectsEx+0x123
02 00000066`9227ef40 00007ffb`4c0257b5     coreclr!FinalizerThread::WaitForFinalizerEvent+0x144 [Q:\source\mdh1418\runtime\src\coreclr\vm\finalizerthread.cpp @ 290] 
03 00000066`9227efb0 00007ffb`4bec5f8d     coreclr!FinalizerThread::FinalizerThreadWorker+0xd5 [Q:\source\mdh1418\runtime\src\coreclr\vm\finalizerthread.cpp @ 376] 
04 00000066`9227f2a0 00007ffb`4bec602c     coreclr!ManagedThreadBase_DispatchInner+0x19d [Q:\source\mdh1418\runtime\src\coreclr\vm\threads.cpp @ 6830] 
05 00000066`9227f3c0 00007ffb`4bec944e     coreclr!ManagedThreadBase_DispatchMiddle+0x6c [Q:\source\mdh1418\runtime\src\coreclr\vm\threads.cpp @ 6874] 
06 00000066`9227f6a0 00007ffb`4bec953d     coreclr!``ManagedThreadBase_DispatchOuter'::`8'::__Body::Run'::`5'::__Body::Run+0x5e [Q:\source\mdh1418\runtime\src\coreclr\vm\threads.cpp @ 7032] 
07 00000066`9227f6f0 00007ffb`4bec6181     coreclr!`ManagedThreadBase_DispatchOuter'::`8'::__Body::Run+0x8d [Q:\source\mdh1418\runtime\src\coreclr\vm\threads.cpp @ 7034] 
08 00000066`9227f790 00007ffb`4bec583f     coreclr!ManagedThreadBase_DispatchOuter+0x111 [Q:\source\mdh1418\runtime\src\coreclr\vm\threads.cpp @ 7054] 
09 00000066`9227f8a0 00007ffb`4c0253bf     coreclr!ManagedThreadBase::KickOff+0x19f [Q:\source\mdh1418\runtime\src\coreclr\vm\threads.cpp @ 7072] 
0a 00000066`9227f9f0 00007ffc`bda7e8d7     coreclr!FinalizerThread::FinalizerThreadStart+0x16f [Q:\source\mdh1418\runtime\src\coreclr\vm\finalizerthread.cpp @ 518] 
0b 00000066`9227fa30 00007ffc`bdebc34c     kernel32!BaseThreadInitThunk+0x17
0c 00000066`9227fa60 00000000`00000000     ntdll!RtlUserThreadStart+0x2c

   7  Id: 84c8.110c4 Suspend: 0 Teb: 00000066`91781000 Unfrozen
 # Child-SP          RetAddr               Call Site
00 00000066`923ff318 00007ffc`bb45cbbf     ntdll!NtWaitForSingleObject+0x14
01 00000066`923ff320 00007ffb`4c214137     KERNELBASE!WaitForSingleObjectEx+0xaf
02 00000066`923ff3c0 00007ffb`4c216a0e     coreclr!CLREventWaitHelper2+0x27 [Q:\source\mdh1418\runtime\src\coreclr\vm\synch.cpp @ 373] 
03 00000066`923ff3f0 00007ffb`4c2141c5     coreclr!`CLREventWaitHelper'::`3'::__Body::Run+0x6e [Q:\source\mdh1418\runtime\src\coreclr\vm\synch.cpp @ 397] 
04 00000066`923ff440 00007ffb`4c2174dd     coreclr!CLREventWaitHelper+0x85 [Q:\source\mdh1418\runtime\src\coreclr\vm\synch.cpp @ 399] 
05 00000066`923ff4e0 00007ffb`4c217049     coreclr!CLREventBase::WaitEx+0x48d [Q:\source\mdh1418\runtime\src\coreclr\vm\synch.cpp @ 466] 
06 00000066`923ff6b0 00007ffb`4b86bd8f     coreclr!CLREventBase::Wait+0x49 [Q:\source\mdh1418\runtime\src\coreclr\vm\synch.cpp @ 413] 
07 00000066`923ff6f0 00007ffb`4b87c65f     coreclr!ep_rt_wait_event_wait+0xaf [Q:\source\mdh1418\runtime\src\coreclr\vm\eventing\eventpipe\ep-rt-coreclr.h @ 725] 
08 00000066`923ff830 00007ffb`4b86a9e2     coreclr!streaming_thread+0x19f [Q:\source\mdh1418\runtime\src\native\eventpipe\ep-session.c @ 124] 
09 00000066`923ff990 00007ffc`bda7e8d7     coreclr!ep_rt_thread_coreclr_start_func+0x32 [Q:\source\mdh1418\runtime\src\coreclr\vm\eventing\eventpipe\ep-rt-coreclr.h @ 850] 
0a 00000066`923ff9e0 00007ffc`bdebc34c     kernel32!BaseThreadInitThunk+0x17
0b 00000066`923ffa10 00000000`00000000     ntdll!RtlUserThreadStart+0x2c

   8  Id: 84c8.f440 Suspend: 0 Teb: 00000066`91783000 Unfrozen ".NET Counter Poller"
 # Child-SP          RetAddr               Call Site
00 00000066`9257b168 00007ffc`bb45df43     ntdll!NtWaitForMultipleObjects+0x14
01 00000066`9257b170 00007ffb`4bebc4c0     KERNELBASE!WaitForMultipleObjectsEx+0x123
02 00000066`9257b460 00007ffb`4bebce4f     coreclr!Thread::DoAppropriateAptStateWait+0x2b0 [Q:\source\mdh1418\runtime\src\coreclr\vm\threads.cpp @ 3143] 
03 00000066`9257b590 00007ffb`4bec96d1     coreclr!Thread::DoAppropriateWaitWorker+0x6df [Q:\source\mdh1418\runtime\src\coreclr\vm\threads.cpp @ 3323] 
04 00000066`9257b960 00007ffb`4bebc689     coreclr!`Thread::DoAppropriateWait'::`9'::__Body::Run+0xb1 [Q:\source\mdh1418\runtime\src\coreclr\vm\threads.cpp @ 3038] 
05 00000066`9257b9e0 00007ffb`4c21746d     coreclr!Thread::DoAppropriateWait+0x189 [Q:\source\mdh1418\runtime\src\coreclr\vm\threads.cpp @ 3040] 
06 00000066`9257bac0 00007ffb`4c217049     coreclr!CLREventBase::WaitEx+0x41d [Q:\source\mdh1418\runtime\src\coreclr\vm\synch.cpp @ 459] 
07 00000066`9257bc90 00007ffb`4bea48fe     coreclr!CLREventBase::Wait+0x49 [Q:\source\mdh1418\runtime\src\coreclr\vm\synch.cpp @ 413] 
08 00000066`9257bcd0 00007ffb`4bea45ff     coreclr!AwareLock::EnterEpilogHelper+0x2be [Q:\source\mdh1418\runtime\src\coreclr\vm\syncblk.cpp @ 2572] 
09 00000066`9257be60 00007ffb`4bea44ed     coreclr!AwareLock::EnterEpilog+0x8f [Q:\source\mdh1418\runtime\src\coreclr\vm\syncblk.cpp @ 2443] 
0a 00000066`9257bf10 00007ffb`4bea4c17     coreclr!AwareLock::Enter+0x45d [Q:\source\mdh1418\runtime\src\coreclr\vm\syncblk.cpp @ 2344] 
0b 00000066`9257c180 00007ffb`4bea4c3c     coreclr!SyncBlock::EnterMonitor+0x17 [Q:\source\mdh1418\runtime\src\coreclr\vm\syncblk.h @ 1031] 
0c 00000066`9257c1b0 00007ffb`4bad2d3c     coreclr!ObjHeader::EnterObjMonitor+0x1c [Q:\source\mdh1418\runtime\src\coreclr\vm\syncblk.cpp @ 1487] 
0d 00000066`9257c1e0 00007ffb`4bad5048     coreclr!Object::EnterObjMonitor+0x1c [Q:\source\mdh1418\runtime\src\coreclr\vm\object.h @ 280] 
0e 00000066`9257c210 00007ffb`44f9a3a7     coreclr!Monitor_Enter_Slowpath+0x238 [Q:\source\mdh1418\runtime\src\coreclr\classlibnative\bcltype\objectnative.cpp @ 199] 
0f 00000066`9257c4a0 00007ffb`44f9a552     System_Private_CoreLib!System.Threading.Monitor.Enter_Slowpath+0x57 [Q:\source\mdh1418\runtime\src\coreclr\System.Private.CoreLib\src\System\Threading\Monitor.CoreCLR.cs @ 73] 
10 00000066`9257c570 00007ffb`450dbc64     System_Private_CoreLib!System.Threading.Monitor.Enter+0x32 [Q:\source\mdh1418\runtime\src\coreclr\System.Private.CoreLib\src\System\Threading\Monitor.CoreCLR.cs @ 123] 
11 00000066`9257c5b0 00007ffb`450d4021     System_Private_CoreLib!System.Diagnostics.Tracing.EventListener.AddEventSource+0x34 [Q:\source\mdh1418\runtime\src\libraries\System.Private.CoreLib\src\System\Diagnostics\Tracing\EventSource.cs @ 4324] 
12 00000066`9257c630 00007ffb`450d3e30     System_Private_CoreLib!System.Diagnostics.Tracing.EventSource.Initialize+0x1e1 [Q:\source\mdh1418\runtime\src\libraries\System.Private.CoreLib\src\System\Diagnostics\Tracing\EventSource.cs @ 1714] 
13 00000066`9257c6e0 00007ffb`44f88d5d     System_Private_CoreLib!System.Diagnostics.Tracing.EventSource..ctor+0x80
14 00000066`9257c730 00007ffb`44f88da7     System_Private_CoreLib!System.Buffers.ArrayPoolEventSource..ctor+0x6d
15 00000066`9257c770 00007ffb`4c4e39d3     System_Private_CoreLib!System.Buffers.ArrayPoolEventSource..cctor+0x17
16 00000066`9257c7a0 00007ffb`4bf63710     coreclr!CallDescrWorkerInternal+0x83 [Q:\source\mdh1418\runtime\src\coreclr\vm\amd64\CallDescrWorkerAMD64.asm @ 74] 
17 00000066`9257c7e0 00007ffb`4bf64be6     coreclr!CallDescrWorkerWithHandler+0x130 [Q:\source\mdh1418\runtime\src\coreclr\vm\callhelpers.cpp @ 59] 
18 00000066`9257c840 00007ffb`4bf643c6     coreclr!`DispatchCallDebuggerWrapper'::`3'::__Body::Run+0x66 [Q:\source\mdh1418\runtime\src\coreclr\vm\callhelpers.cpp @ 139] 
19 00000066`9257c890 00007ffb`4bf64690     coreclr!DispatchCallDebuggerWrapper+0x76 [Q:\source\mdh1418\runtime\src\coreclr\vm\callhelpers.cpp @ 143] 
1a 00000066`9257c930 00007ffb`4bdf14e4     coreclr!DispatchCallSimple+0x250 [Q:\source\mdh1418\runtime\src\coreclr\vm\callhelpers.cpp @ 233] 
1b 00000066`9257cac0 00007ffb`4bdd647f     coreclr!MethodTable::RunClassInitEx+0x5b4 [Q:\source\mdh1418\runtime\src\coreclr\vm\methodtable.cpp @ 3545] 
1c 00000066`9257cee0 00007ffb`4bdcf79f     coreclr!MethodTable::DoRunClassInitThrowing+0x81f [Q:\source\mdh1418\runtime\src\coreclr\vm\methodtable.cpp @ 3727] 
1d 00000066`9257de20 00007ffb`4be3f12d     coreclr!MethodTable::CheckRunClassInitThrowing+0x42f [Q:\source\mdh1418\runtime\src\coreclr\vm\methodtable.cpp @ 3852] 
1e 00000066`9257e050 00007ffb`4be4a59e     coreclr!DynamicHelperFixup+0x55d [Q:\source\mdh1418\runtime\src\coreclr\vm\prestub.cpp @ 3193] 
1f 00000066`9257e770 00007ffb`4c4e547a     coreclr!DynamicHelperWorker+0x26e [Q:\source\mdh1418\runtime\src\coreclr\vm\prestub.cpp @ 3504] 
20 00000066`9257eaf0 00007ffb`45127372     coreclr!DelayLoad_Helper+0x7a [Q:\source\mdh1418\runtime\src\coreclr\vm\amd64\ExternalMethodFixupThunk.asm @ 59] 
21 00000066`9257ebb0 00007ffb`45033528     System_Private_CoreLib!System.Buffers.SharedArrayPool<char>.Rent+0x22 [Q:\source\mdh1418\runtime\src\libraries\System.Private.CoreLib\src\System\Buffers\SharedArrayPool.cs @ 52] 
22 00000066`9257ec40 00007ffb`450e3789     System_Private_CoreLib!System.Runtime.CompilerServices.DefaultInterpolatedStringHandler..ctor+0x38 [Q:\source\mdh1418\runtime\src\libraries\System.Private.CoreLib\src\System\Runtime\CompilerServices\DefaultInterpolatedStringHandler.cs @ 58] 
23 00000066`9257ec80 00007ffb`450ca7c8     System_Private_CoreLib!System.Diagnostics.Tracing.PollingCounter.WritePayload+0xe9 [Q:\source\mdh1418\runtime\src\libraries\System.Private.CoreLib\src\System\Diagnostics\Tracing\PollingCounter.cs @ 64] 
24 00000066`9257ed70 00007ffb`450caa05     System_Private_CoreLib!System.Diagnostics.Tracing.CounterGroup.OnTimer+0xd8 [Q:\source\mdh1418\runtime\src\libraries\System.Private.CoreLib\src\System\Diagnostics\Tracing\CounterGroup.cs @ 256] 
25 00000066`9257ee20 00007ffb`44f9afff     System_Private_CoreLib!System.Diagnostics.Tracing.CounterGroup.PollForValues+0xf5 [Q:\source\mdh1418\runtime\src\libraries\System.Private.CoreLib\src\System\Diagnostics\Tracing\CounterGroup.cs @ 323] 
26 00000066`9257ef10 00007ffb`4c4e39d3     System_Private_CoreLib!System.Threading.Thread.StartCallback+0x8f [Q:\source\mdh1418\runtime\src\coreclr\System.Private.CoreLib\src\System\Threading\Thread.CoreCLR.cs @ 108] 
27 00000066`9257ef50 00007ffb`4bf63710     coreclr!CallDescrWorkerInternal+0x83 [Q:\source\mdh1418\runtime\src\coreclr\vm\amd64\CallDescrWorkerAMD64.asm @ 74] 
28 00000066`9257ef90 00007ffb`4bf646ac     coreclr!CallDescrWorkerWithHandler+0x130 [Q:\source\mdh1418\runtime\src\coreclr\vm\callhelpers.cpp @ 59] 
29 00000066`9257eff0 00007ffb`4bf96807     coreclr!DispatchCallSimple+0x26c [Q:\source\mdh1418\runtime\src\coreclr\vm\callhelpers.cpp @ 239] 
2a 00000066`9257f180 00007ffb`4bec5f8d     coreclr!KickOffThread_Worker+0x3c7 [Q:\source\mdh1418\runtime\src\coreclr\vm\comsynchronizable.cpp @ 137] 
2b 00000066`9257f390 00007ffb`4bec602c     coreclr!ManagedThreadBase_DispatchInner+0x19d [Q:\source\mdh1418\runtime\src\coreclr\vm\threads.cpp @ 6830] 
2c 00000066`9257f4b0 00007ffb`4bec944e     coreclr!ManagedThreadBase_DispatchMiddle+0x6c [Q:\source\mdh1418\runtime\src\coreclr\vm\threads.cpp @ 6874] 
2d 00000066`9257f790 00007ffb`4bec953d     coreclr!``ManagedThreadBase_DispatchOuter'::`8'::__Body::Run'::`5'::__Body::Run+0x5e [Q:\source\mdh1418\runtime\src\coreclr\vm\threads.cpp @ 7032] 
2e 00000066`9257f7e0 00007ffb`4bec6181     coreclr!`ManagedThreadBase_DispatchOuter'::`8'::__Body::Run+0x8d [Q:\source\mdh1418\runtime\src\coreclr\vm\threads.cpp @ 7034] 
2f 00000066`9257f880 00007ffb`4bec583f     coreclr!ManagedThreadBase_DispatchOuter+0x111 [Q:\source\mdh1418\runtime\src\coreclr\vm\threads.cpp @ 7054] 
30 00000066`9257f990 00007ffb`4bf963a8     coreclr!ManagedThreadBase::KickOff+0x19f [Q:\source\mdh1418\runtime\src\coreclr\vm\threads.cpp @ 7072] 
31 00000066`9257fae0 00007ffc`bda7e8d7     coreclr!KickOffThread+0x278 [Q:\source\mdh1418\runtime\src\coreclr\vm\comsynchronizable.cpp @ 206] 
32 00000066`9257fcd0 00007ffc`bdebc34c     kernel32!BaseThreadInitThunk+0x17
33 00000066`9257fd00 00000000`00000000     ntdll!RtlUserThreadStart+0x2c

Reproduction Steps

It should repro with just dotnet run, but I've mostly been hitting this through corerun <app>.dll and corerun --debug <app>.dll.

With a simple console app

Terminal window 1: corerun <app>.dll

Immediately afterwards,
Terminal window 2: dontet-counters collect/monitor -n corerun

Expected behavior

The .NET app progresses and counters are collected/monitored.

Actual behavior

.NET app stalls and counters makes no progress

Regression?

No, this has been a recurring issue with EventSource callbacks.

Known Workarounds

Start dotnet-counters later instead of immediately after
or
Start the .NET app as a child process of dotnet-counters (this seemed to work)

Configuration

No response

Other information

No response

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions