question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ServiceHub.RoslynCodeAnalysisService.exe or devenv.exe could consume a CPU core permanently

See original GitHub issue

Version Used: Since VS 17.4 preview 3 Steps to Reproduce:

It is hard to reproduce it with a describable procedure.

I posted this issue initially on VS feedback, but no reply were heard for days. It occurred quite a few times a day on my computer.

When this issue occurs, ServiceHub.RoslynCodeAnalysisService.exe or sometimes devenv.exe, will consume all resource of a CPU core and its usage ratio won’t subside.

I used Process Explorer to find out that the problematic thread has the following stack in ServiceHub.RoslynCodeAnalysisService.exe, when its CPU consumption rate was high:

System.Core.dll!System.Collections.Generic.HashSet`1.Contains+0xbe
Microsoft.CodeAnalysis.dll!Microsoft.CodeAnalysis.Diagnostics.AnalyzerExecutor.ShouldExecuteNode+0x23
Microsoft.CodeAnalysis.dll!Microsoft.CodeAnalysis.Diagnostics.AnalyzerExecutor.ExecuteSyntaxNodeActions+0xfd
Microsoft.CodeAnalysis.dll!Microsoft.CodeAnalysis.Diagnostics.AnalyzerExecutor.ExecuteSyntaxNodeActionsCore+0x1f6
Microsoft.CodeAnalysis.dll!Microsoft.CodeAnalysis.Diagnostics.AnalyzerExecutor.TryExecuteSyntaxNodeActions+0xda
Microsoft.CodeAnalysis.dll!<>c__DisplayClass12_0.<TryExecuteDeclaringReferenceActions>g__executeNodeActionsByKind|2+0x232
Microsoft.CodeAnalysis.dll!<>c__DisplayClass12_0.<TryExecuteDeclaringReferenceActions>g__executeNodeActions|1+0x2a
Microsoft.CodeAnalysis.dll!Microsoft.CodeAnalysis.Diagnostics.AnalyzerDriver`1.TryExecuteDeclaringReferenceActions+0x2c9
Microsoft.CodeAnalysis.dll!Microsoft.CodeAnalysis.Diagnostics.AnalyzerDriver`1.TryExecuteDeclaringReferenceActions+0x420
Microsoft.CodeAnalysis.dll!<TryProcessSymbolDeclaredAsync>d__133.MoveNext+0x40c
mscorlib.dll!System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1.Start+0x7a
Microsoft.CodeAnalysis.dll!Microsoft.CodeAnalysis.Diagnostics.AnalyzerDriver.TryProcessSymbolDeclaredAsync+0x8b
Microsoft.CodeAnalysis.dll!<TryProcessEventCoreAsync>d__132.MoveNext+0x1e4
mscorlib.dll!System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1.Start+0x7a
Microsoft.CodeAnalysis.dll!Microsoft.CodeAnalysis.Diagnostics.AnalyzerDriver.TryProcessEventCoreAsync+0x8b
Microsoft.CodeAnalysis.dll!<ProcessEventAsync>d__130.MoveNext+0x8f
mscorlib.dll!System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start+0x80
Microsoft.CodeAnalysis.dll!Microsoft.CodeAnalysis.Diagnostics.AnalyzerDriver.ProcessEventAsync+0x70
Microsoft.CodeAnalysis.dll!<ProcessCompilationEventsCoreAsync>d__129.MoveNext+0x456
mscorlib.dll!System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1.Start+0x7a
Microsoft.CodeAnalysis.dll!Microsoft.CodeAnalysis.Diagnostics.AnalyzerDriver.ProcessCompilationEventsCoreAsync+0x7d
Microsoft.CodeAnalysis.dll!<<ProcessCompilationEventsAsync>b__2>d.MoveNext+0x61
mscorlib.dll!System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1.Start+0x7a
Microsoft.CodeAnalysis.dll!<>c__DisplayClass128_0.<ProcessCompilationEventsAsync>b__2+0x59
mscorlib.dll!System.Threading.Tasks.Task`1.InnerInvoke+0x4e
mscorlib.dll!System.Threading.Tasks.Task.Execute+0x47
mscorlib.dll!System.Threading.ExecutionContext.RunInternal+0x172
mscorlib.dll!System.Threading.ExecutionContext.Run+0x15
mscorlib.dll!System.Threading.Tasks.Task.ExecuteWithThreadLocal+0x231
mscorlib.dll!System.Threading.Tasks.Task.ExecuteEntry+0xa1
mscorlib.dll!System.Threading.ThreadPoolWorkQueue.Dispatch+0x156
[Unmanaged to Managed Transition]
clr.dll!LogHelp_LogAssert+0x1b63
clr.dll!LogHelp_LogAssert+0x1a80
clr.dll!LogHelp_LogAssert+0x2320
clr.dll!MetaDataGetDispenser+0x12efa
clr.dll!LogHelp_LogAssert+0x2f08
clr.dll!LogHelp_LogAssert+0x2e73
clr.dll!LogHelp_LogAssert+0x2db2
clr.dll!LogHelp_LogAssert+0x5cc5
clr.dll!LogHelp_LogAssert+0x5dbb
clr.dll!LogHelp_LogAssert+0x5d17
clr.dll!LogHelp_LogAssert+0x2e73
clr.dll!LogHelp_LogAssert+0x2db2
clr.dll!LogHelp_LogAssert+0x2fa3
clr.dll!MetaDataGetDispenser+0x12e47
clr.dll!LogHelp_LogAssert+0x2abf
clr.dll!LogHelp_LogAssert+0x298f
clr.dll!DllCanUnloadNowInternal+0xca5
KERNEL32.dll!BaseThreadInitThunk+0x14
ntdll.dll!RtlUserThreadStart+0x21

And a second time I used WinDbg to find out the stack of devenv.exe, when this issue occurred on it.

Current frame: (MethodDesc 00007ffdd64d3648 +0xbe System.Collections.Generic.HashSet`1[[System.__Canon, mscorlib]].Contains(System.__Canon))
Child-SP         RetAddr          Caller, Callee
000000808fc3c950 00007ffde40610c3 (MethodDesc 00007ffde1cb9f28 +0x23 Microsoft.CodeAnalysis.Diagnostics.AnalyzerExecutor.ShouldExecuteNode(SyntaxNodeAnalyzerStateData, Microsoft.CodeAnalysis.SyntaxNode, Microsoft.CodeAnalysis.Diagnostics.DiagnosticAnalyzer))
000000808fc3c9a0 00007ffde4060f5d (MethodDesc 00007ffde42aa148 +0xfd Microsoft.CodeAnalysis.Diagnostics.AnalyzerExecutor.ExecuteSyntaxNodeActions[[Microsoft.CodeAnalysis.CSharp.SyntaxKind, Microsoft.CodeAnalysis.CSharp]](System.Collections.Generic.IEnumerable`1<Microsoft.CodeAnalysis.SyntaxNode>, Microsoft.CodeAnalysis.Collections.ImmutableSegmentedDictionary`2<Microsoft.CodeAnalysis.CSharp.SyntaxKind,System.Collections.Immutable.ImmutableArray`1<Microsoft.CodeAnalysis.Diagnostics.SyntaxNodeAnalyzerAction`1<Microsoft.CodeAnalysis.CSharp.SyntaxKind>>>, Microsoft.CodeAnalysis.Diagnostics.DiagnosticAnalyzer, Microsoft.CodeAnalysis.ISymbol, Microsoft.CodeAnalysis.SemanticModel, System.Func`2<Microsoft.CodeAnalysis.SyntaxNode,Microsoft.CodeAnalysis.CSharp.SyntaxKind>, System.Action`1<Microsoft.CodeAnalysis.Diagnostic>, System.Func`2<Microsoft.CodeAnalysis.Diagnostic,Boolean>, Boolean, SyntaxNodeAnalyzerStateData))
000000808fc3c9b0 00007ffddade46b0 (MethodDesc 00007ffddb55c6a0 +0x20 Microsoft.CodeAnalysis.PooledObjects.ObjectPool`1[[System.__Canon, mscorlib]].Allocate())
000000808fc3c9f0 00007ffde3b3fc59 (MethodDesc 00007ffde3e65058 +0x89 Microsoft.CodeAnalysis.PooledObjects.PooledDelegates.GetPooledDelegate[[System.__Canon, mscorlib],[System.ValueTuple`2[[System.__Canon, mscorlib],[System.__Canon, mscorlib]], mscorlib],[System.__Canon, mscorlib],[System.__Canon, mscorlib]](System.__Canon, System.ValueTuple`2<System.__Canon,System.__Canon>, System.__Canon ByRef))
000000808fc3ca50 00007ffde4060c76 (MethodDesc 00007ffde42a8168 +0x1f6 Microsoft.CodeAnalysis.Diagnostics.AnalyzerExecutor.ExecuteSyntaxNodeActionsCore[[Microsoft.CodeAnalysis.CSharp.SyntaxKind, Microsoft.CodeAnalysis.CSharp]](System.Collections.Generic.IEnumerable`1<Microsoft.CodeAnalysis.SyntaxNode>, Microsoft.CodeAnalysis.Collections.ImmutableSegmentedDictionary`2<Microsoft.CodeAnalysis.CSharp.SyntaxKind,System.Collections.Immutable.ImmutableArray`1<Microsoft.CodeAnalysis.Diagnostics.SyntaxNodeAnalyzerAction`1<Microsoft.CodeAnalysis.CSharp.SyntaxKind>>>, Microsoft.CodeAnalysis.Diagnostics.DiagnosticAnalyzer, Microsoft.CodeAnalysis.ISymbol, Microsoft.CodeAnalysis.SemanticModel, System.Func`2<Microsoft.CodeAnalysis.SyntaxNode,Microsoft.CodeAnalysis.CSharp.SyntaxKind>, Microsoft.CodeAnalysis.Text.TextSpan, SyntaxNodeAnalyzerStateData, Boolean))
000000808fc3cb60 00007ffde406040a (MethodDesc 00007ffde427f228 +0xda Microsoft.CodeAnalysis.Diagnostics.AnalyzerExecutor.TryExecuteSyntaxNodeActions[[Microsoft.CodeAnalysis.CSharp.SyntaxKind, Microsoft.CodeAnalysis.CSharp]](System.Collections.Generic.IEnumerable`1<Microsoft.CodeAnalysis.SyntaxNode>, Microsoft.CodeAnalysis.Collections.ImmutableSegmentedDictionary`2<Microsoft.CodeAnalysis.CSharp.SyntaxKind,System.Collections.Immutable.ImmutableArray`1<Microsoft.CodeAnalysis.Diagnostics.SyntaxNodeAnalyzerAction`1<Microsoft.CodeAnalysis.CSharp.SyntaxKind>>>, Microsoft.CodeAnalysis.Diagnostics.DiagnosticAnalyzer, Microsoft.CodeAnalysis.SemanticModel, System.Func`2<Microsoft.CodeAnalysis.SyntaxNode,Microsoft.CodeAnalysis.CSharp.SyntaxKind>, Microsoft.CodeAnalysis.Text.TextSpan, Int32, Microsoft.CodeAnalysis.ISymbol, Microsoft.CodeAnalysis.Diagnostics.AnalysisScope, Microsoft.CodeAnalysis.Diagnostics.AnalysisState, Boolean))
000000808fc3cc10 00007ffde4059942 (MethodDesc 00007ffde4276060 +0x232 Microsoft.CodeAnalysis.Diagnostics.AnalyzerDriver`1+<>c__DisplayClass12_0[[Microsoft.CodeAnalysis.CSharp.SyntaxKind, Microsoft.CodeAnalysis.CSharp]].<TryExecuteDeclaringReferenceActions>g__executeNodeActionsByKind|2(Microsoft.CodeAnalysis.Diagnostics.AnalysisScope, System.Collections.Immutable.ImmutableArray`1<Microsoft.CodeAnalysis.SyntaxNode>, GroupedAnalyzerActions<Microsoft.CodeAnalysis.CSharp.SyntaxKind>))
000000808fc3cd60 00007ffde405832a (MethodDesc 00007ffde4276058 +0x2a Microsoft.CodeAnalysis.Diagnostics.AnalyzerDriver`1+<>c__DisplayClass12_0[[Microsoft.CodeAnalysis.CSharp.SyntaxKind, Microsoft.CodeAnalysis.CSharp]].<TryExecuteDeclaringReferenceActions>g__executeNodeActions|1())
000000808fc3cda0 00007ffde4052b79 (MethodDesc 00007ffde3d22b68 +0x2c9 Microsoft.CodeAnalysis.Diagnostics.AnalyzerDriver`1[[Microsoft.CodeAnalysis.CSharp.SyntaxKind, Microsoft.CodeAnalysis.CSharp]].TryExecuteDeclaringReferenceActions(Microsoft.CodeAnalysis.SyntaxReference, Int32, Microsoft.CodeAnalysis.Diagnostics.SymbolDeclaredCompilationEvent, Microsoft.CodeAnalysis.Diagnostics.AnalysisScope, Microsoft.CodeAnalysis.Diagnostics.AnalysisState, GroupedAnalyzerActions<Microsoft.CodeAnalysis.CSharp.SyntaxKind>, GroupedAnalyzerActions<Microsoft.CodeAnalysis.CSharp.SyntaxKind>, Boolean, Boolean, Boolean, Boolean, Boolean, System.Threading.CancellationToken))
000000808fc3ce40 00007ffde4050f10 (MethodDesc 00007ffde3d22b48 +0x420 Microsoft.CodeAnalysis.Diagnostics.AnalyzerDriver`1[[Microsoft.CodeAnalysis.CSharp.SyntaxKind, Microsoft.CodeAnalysis.CSharp]].TryExecuteDeclaringReferenceActions(Microsoft.CodeAnalysis.Diagnostics.SymbolDeclaredCompilationEvent, Microsoft.CodeAnalysis.Diagnostics.AnalysisScope, Microsoft.CodeAnalysis.Diagnostics.AnalysisState, Boolean, IGroupedAnalyzerActions, System.Threading.CancellationToken))
000000808fc3d030 00007ffde404c61c (MethodDesc 00007ffde4251b40 +0x40c Microsoft.CodeAnalysis.Diagnostics.AnalyzerDriver+<TryProcessSymbolDeclaredAsync>d__133.MoveNext())
000000808fc3d078 00007ffe333ee719 (MethodDesc 00007ffe32737658 +0x49 System.Threading.AsyncLocalValueMap+MultiElementAsyncLocalValueMap.TryGetValue(System.Threading.IAsyncLocal, System.Object ByRef))
000000808fc3d1e0 00007ffde404c19a (MethodDesc 00007ffde42572c0 +0x7a System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1[[System.__Canon, mscorlib]].Start[[Microsoft.CodeAnalysis.Diagnostics.AnalyzerDriver+<TryProcessSymbolDeclaredAsync>d__133, Microsoft.CodeAnalysis]](<TryProcessSymbolDeclaredAsync>d__133 ByRef))
000000808fc3d290 00007ffde404c0db (MethodDesc 00007ffde20d2ff0 +0x8b Microsoft.CodeAnalysis.Diagnostics.AnalyzerDriver.TryProcessSymbolDeclaredAsync(Microsoft.CodeAnalysis.Diagnostics.SymbolDeclaredCompilationEvent, Microsoft.CodeAnalysis.Diagnostics.AnalysisScope, Microsoft.CodeAnalysis.Diagnostics.AnalysisState, System.Threading.CancellationToken))
000000808fc3d2b0 00007ffe329dd05f (MethodDesc 00007ffe325c3680 +0xbf System.Runtime.CompilerServices.AsyncMethodBuilderCore+MoveNextRunner.Run())
000000808fc3d340 00007ffde4047de4 (MethodDesc 00007ffde4250d08 +0x1e4 Microsoft.CodeAnalysis.Diagnostics.AnalyzerDriver+<TryProcessEventCoreAsync>d__132.MoveNext())
000000808fc3d460 00007ffde4047b8a (MethodDesc 00007ffde42518a0 +0x7a System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1[[System.__Canon, mscorlib]].Start[[Microsoft.CodeAnalysis.Diagnostics.AnalyzerDriver+<TryProcessEventCoreAsync>d__132, Microsoft.CodeAnalysis]](<TryProcessEventCoreAsync>d__132 ByRef))
000000808fc3d480 00007ffdd658f6f0 (MethodDesc 00007ffdd6609970 +0x200 System.Collections.Concurrent.ConcurrentDictionary`2[[System.Int32, mscorlib],[System.Nullable`1[[Microsoft.VisualStudio.Threading.JoinableTaskInternals+JoinableTaskToken, Microsoft.VisualStudio.Threading]], mscorlib]].TryRemoveInternal(Int32, System.Nullable`1<JoinableTaskToken> ByRef, Boolean, System.Nullable`1<JoinableTaskToken>))
000000808fc3d510 00007ffde4047acb (MethodDesc 00007ffde20d2fe0 +0x8b Microsoft.CodeAnalysis.Diagnostics.AnalyzerDriver.TryProcessEventCoreAsync(Microsoft.CodeAnalysis.Diagnostics.CompilationEvent, Microsoft.CodeAnalysis.Diagnostics.AnalysisScope, Microsoft.CodeAnalysis.Diagnostics.AnalysisState, System.Threading.CancellationToken))
000000808fc3d520 00007ffdd658f103 (MethodDesc 00007ffdd6609968 +0x33 System.Collections.Concurrent.ConcurrentDictionary`2[[System.Int32, mscorlib],[System.Nullable`1[[Microsoft.VisualStudio.Threading.JoinableTaskInternals+JoinableTaskToken, Microsoft.VisualStudio.Threading]], mscorlib]].TryRemove(Int32, System.Nullable`1<JoinableTaskToken> ByRef))
000000808fc3d5c0 00007ffde404763f (MethodDesc 00007ffde3e60788 +0x8f Microsoft.CodeAnalysis.Diagnostics.AnalyzerDriver+<ProcessEventAsync>d__130.MoveNext())
000000808fc3d700 00007ffde4047540 (MethodDesc 00007ffde4250858 +0x80 System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[[Microsoft.CodeAnalysis.Diagnostics.AnalyzerDriver+<ProcessEventAsync>d__130, Microsoft.CodeAnalysis]](<ProcessEventAsync>d__130 ByRef))
000000808fc3d7b0 00007ffde4047490 (MethodDesc 00007ffde20d2fc0 +0x70 Microsoft.CodeAnalysis.Diagnostics.AnalyzerDriver.ProcessEventAsync(Microsoft.CodeAnalysis.Diagnostics.CompilationEvent, Microsoft.CodeAnalysis.Diagnostics.AnalysisScope, Microsoft.CodeAnalysis.Diagnostics.AnalysisState, System.Threading.CancellationToken))
000000808fc3d7c0 00007ffde3b345df (MethodDesc 00007ffddb9e02a8 +0x7f Microsoft.CodeAnalysis.Diagnostics.AsyncQueue`1[[System.__Canon, mscorlib]].get_Count())
000000808fc3d860 00007ffde3b3b616 (MethodDesc 00007ffde3e60210 +0x456 Microsoft.CodeAnalysis.Diagnostics.AnalyzerDriver+<ProcessCompilationEventsCoreAsync>d__129.MoveNext())
000000808fc3da00 00007ffde3b3b14a (MethodDesc 00007ffde3e60cb0 +0x7a System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1[[System.__Canon, mscorlib]].Start[[Microsoft.CodeAnalysis.Diagnostics.AnalyzerDriver+<ProcessCompilationEventsCoreAsync>d__129, Microsoft.CodeAnalysis]](<ProcessCompilationEventsCoreAsync>d__129 ByRef))
000000808fc3dab0 00007ffde3b3b08d (MethodDesc 00007ffde20d2fb0 +0x7d Microsoft.CodeAnalysis.Diagnostics.AnalyzerDriver.ProcessCompilationEventsCoreAsync(Microsoft.CodeAnalysis.Diagnostics.AnalysisScope, Microsoft.CodeAnalysis.Diagnostics.AnalysisState, Boolean, System.Threading.CancellationToken))
000000808fc3db60 00007ffde3b3abb1 (MethodDesc 00007ffde3e3f478 +0x531 Microsoft.CodeAnalysis.Diagnostics.AnalyzerDriver+<ProcessCompilationEventsAsync>d__128.MoveNext())
000000808fc3dc40 00007ffde3b3a200 (MethodDesc 00007ffde3e3f6d0 +0x80 System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[[Microsoft.CodeAnalysis.Diagnostics.AnalyzerDriver+<ProcessCompilationEventsAsync>d__128, Microsoft.CodeAnalysis]](<ProcessCompilationEventsAsync>d__128 ByRef))
000000808fc3dc50 00007ffdd658f103 (MethodDesc 00007ffdd6609968 +0x33 System.Collections.Concurrent.ConcurrentDictionary`2[[System.Int32, mscorlib],[System.Nullable`1[[Microsoft.VisualStudio.Threading.JoinableTaskInternals+JoinableTaskToken, Microsoft.VisualStudio.Threading]], mscorlib]].TryRemove(Int32, System.Nullable`1<JoinableTaskToken> ByRef))
000000808fc3dc70 00007ffde3ad529f (MethodDesc 00007ffde1cb9a98 +0x16f Microsoft.CodeAnalysis.Diagnostics.AnalyzerExecutor..ctor(Microsoft.CodeAnalysis.Compilation, Microsoft.CodeAnalysis.Diagnostics.AnalyzerOptions, System.Action`1<Microsoft.CodeAnalysis.Diagnostic>, System.Action`3<System.Exception,Microsoft.CodeAnalysis.Diagnostics.DiagnosticAnalyzer,Microsoft.CodeAnalysis.Diagnostic>, System.Func`2<System.Exception,Boolean>, System.Func`2<Microsoft.CodeAnalysis.Diagnostics.DiagnosticAnalyzer,Boolean>, Microsoft.CodeAnalysis.Diagnostics.AnalyzerManager, System.Func`2<Microsoft.CodeAnalysis.Diagnostics.DiagnosticAnalyzer,Boolean>, System.Func`5<Microsoft.CodeAnalysis.Diagnostic,Microsoft.CodeAnalysis.Diagnostics.DiagnosticAnalyzer,Microsoft.CodeAnalysis.Compilation,System.Threading.CancellationToken,Boolean>, System.Func`3<Microsoft.CodeAnalysis.SyntaxTree,Microsoft.CodeAnalysis.Text.TextSpan,Boolean>, System.Func`4<Microsoft.CodeAnalysis.Diagnostics.DiagnosticAnalyzer,Microsoft.CodeAnalysis.SyntaxTree,Microsoft.CodeAnalysis.SyntaxTreeOptionsProvider,Boolean>, System.Func`2<Microsoft.CodeAnalysis.Diagnostics.DiagnosticAnalyzer,System.Object>, System.Func`2<Microsoft.CodeAnalysis.SyntaxTree,Microsoft.CodeAnalysis.SemanticModel>, System.Collections.Concurrent.ConcurrentDictionary`2<Microsoft.CodeAnalysis.Diagnostics.DiagnosticAnalyzer,System.Runtime.CompilerServices.StrongBox`1<Int64>>, System.Action`3<Microsoft.CodeAnalysis.Diagnostic,Microsoft.CodeAnalysis.Diagnostics.DiagnosticAnalyzer,Boolean>, System.Action`2<Microsoft.CodeAnalysis.Diagnostic,Microsoft.CodeAnalysis.Diagnostics.DiagnosticAnalyzer>, System.Action`1<Microsoft.CodeAnalysis.Diagnostics.Suppression>, System.Threading.CancellationToken))
000000808fc3dcf0 00007ffde3b3a146 (MethodDesc 00007ffde20d2fa0 +0x76 Microsoft.CodeAnalysis.Diagnostics.AnalyzerDriver.ProcessCompilationEventsAsync(Microsoft.CodeAnalysis.Diagnostics.AnalysisScope, Microsoft.CodeAnalysis.Diagnostics.AnalysisState, Boolean, System.Threading.CancellationToken))
000000808fc3ddb0 00007ffde3b39f40 (MethodDesc 00007ffde3e3f0a8 +0x1c0 Microsoft.CodeAnalysis.Diagnostics.AnalyzerDriver+<ExecutePrimaryAnalysisTaskAsync>d__96.MoveNext())
000000808fc3de40 00007ffde3b39d10 (MethodDesc 00007ffde3e3f280 +0x80 System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[[Microsoft.CodeAnalysis.Diagnostics.AnalyzerDriver+<ExecutePrimaryAnalysisTaskAsync>d__96, Microsoft.CodeAnalysis]](<ExecutePrimaryAnalysisTaskAsync>d__96 ByRef))
000000808fc3def0 00007ffde3b39c60 (MethodDesc 00007ffde20d2dd0 +0x70 Microsoft.CodeAnalysis.Diagnostics.AnalyzerDriver.ExecutePrimaryAnalysisTaskAsync(Microsoft.CodeAnalysis.Diagnostics.AnalysisScope, Microsoft.CodeAnalysis.Diagnostics.AnalysisState, Boolean, System.Threading.CancellationToken))
000000808fc3df80 00007ffde3b3998f (MethodDesc 00007ffde3e3ed88 +0xff Microsoft.CodeAnalysis.Diagnostics.AnalyzerDriver+<AttachQueueAndProcessAllEventsAsync>d__94.MoveNext())
000000808fc3dfa0 00007ffdd658f762 (MethodDesc 00007ffdd6609970 +0x272 System.Collections.Concurrent.ConcurrentDictionary`2[[System.Int32, mscorlib],[System.Nullable`1[[Microsoft.VisualStudio.Threading.JoinableTaskInternals+JoinableTaskToken, Microsoft.VisualStudio.Threading]], mscorlib]].TryRemoveInternal(Int32, System.Nullable`1<JoinableTaskToken> ByRef, Boolean, System.Nullable`1<JoinableTaskToken>))
000000808fc3e050 00007ffde3b39820 (MethodDesc 00007ffde3e3ef60 +0x80 System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[[Microsoft.CodeAnalysis.Diagnostics.AnalyzerDriver+<AttachQueueAndProcessAllEventsAsync>d__94, Microsoft.CodeAnalysis]](<AttachQueueAndProcessAllEventsAsync>d__94 ByRef))
000000808fc3e100 00007ffde3b3976d (MethodDesc 00007ffde20d2db0 +0x6d Microsoft.CodeAnalysis.Diagnostics.AnalyzerDriver.AttachQueueAndProcessAllEventsAsync(Microsoft.CodeAnalysis.Diagnostics.AsyncQueue`1<Microsoft.CodeAnalysis.Diagnostics.CompilationEvent>, Microsoft.CodeAnalysis.Diagnostics.AnalysisScope, Microsoft.CodeAnalysis.Diagnostics.AnalysisState, System.Threading.CancellationToken))
000000808fc3e110 00007ffdd6337415 (MethodDesc 00007ffdd64d37e0 +0x55 System.Collections.Generic.HashSet`1[[System.__Canon, mscorlib]].InternalGetHashCode(System.__Canon))
000000808fc3e190 00007ffde3b38f9c (MethodDesc 00007ffde3e3e930 +0xbc Microsoft.CodeAnalysis.Diagnostics.CompilationWithAnalyzers+<ComputeAnalyzerDiagnosticsCoreAsync>d__72.MoveNext())
000000808fc3e1b0 00007ffe3331b878 (MethodDesc 00007ffe3274a038 +0x1b8 System.Threading.SemaphoreSlim.Release(Int32))
000000808fc3e1c0 00007ffdd854776e (MethodDesc 00007ffdd88ff358 +0x19e System.Collections.Immutable.ImmutableExtensions.ToArray[[System.__Canon, mscorlib]](System.Collections.Generic.IEnumerable`1<System.__Canon>, Int32))
000000808fc3e240 00007ffde3b38e70 (MethodDesc 00007ffde3e3eb08 +0x80 System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[[Microsoft.CodeAnalysis.Diagnostics.CompilationWithAnalyzers+<ComputeAnalyzerDiagnosticsCoreAsync>d__72, Microsoft.CodeAnalysis]](<ComputeAnalyzerDiagnosticsCoreAsync>d__72 ByRef))
000000808fc3e250 00007ffde1ea404f (MethodDesc 00007ffddb9e02c0 +0x1ef Microsoft.CodeAnalysis.Diagnostics.AsyncQueue`1[[System.__Canon, mscorlib]].EnqueueCore(System.__Canon))
000000808fc3e260 00007ffdd6339dfa (MethodDesc 00007ffdd650c5b8 +0x6a System.Collections.Generic.Queue`1[[System.__Canon, mscorlib]].Enqueue(System.__Canon))
000000808fc3e2f0 00007ffde3b38dbd (MethodDesc 00007ffdde1a4a88 +0x6d Microsoft.CodeAnalysis.Diagnostics.CompilationWithAnalyzers.ComputeAnalyzerDiagnosticsCoreAsync(Microsoft.CodeAnalysis.Diagnostics.AnalyzerDriver, Microsoft.CodeAnalysis.Diagnostics.AsyncQueue`1<Microsoft.CodeAnalysis.Diagnostics.CompilationEvent>, Microsoft.CodeAnalysis.Diagnostics.AnalysisScope, System.Threading.CancellationToken))
000000808fc3e380 00007ffde3b38a3a (MethodDesc 00007ffde3e3e680 +0x11a Microsoft.CodeAnalysis.Diagnostics.CompilationWithAnalyzers+<>c__DisplayClass67_1+<<ComputeAnalyzerDiagnosticsAsync>b__1>d.MoveNext())
000000808fc3e398 00007ffdd658dd01 (MethodDesc 00007ffdd660b610 +0x71 DomainNeutralILStubClass.IL_STUB_PInvoke())
000000808fc3e410 00007ffde3b388b0 (MethodDesc 00007ffde3e3e7e8 +0x80 System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[[Microsoft.CodeAnalysis.Diagnostics.CompilationWithAnalyzers+<>c__DisplayClass67_1+<<ComputeAnalyzerDiagnosticsAsync>b__1>d, Microsoft.CodeAnalysis]](<<ComputeAnalyzerDiagnosticsAsync>b__1>d ByRef))
000000808fc3e420 00007ffdd658db72 (MethodDesc 00007ffdd64bda00 +0x72 Microsoft.VisualStudio.Services.VsHostExecutionContextEvents.OnSetHostExecutionContext())
000000808fc3e440 00007ffe329b7570 (MethodDesc 00007ffe326ffef8 +0x10 System.Threading.HostExecutionContextManager.CheckIfHosted())
000000808fc3e4c0 00007ffde3b387fe (MethodDesc 00007ffde3d21230 +0x4e Microsoft.CodeAnalysis.Diagnostics.CompilationWithAnalyzers+<>c__DisplayClass67_1.<ComputeAnalyzerDiagnosticsAsync>b__1())
000000808fc3e540 00007ffe329dbe4e (MethodDesc 00007ffe325c4448 +0x4e System.Threading.Tasks.Task`1[[System.__Canon, mscorlib]].InnerInvoke())
000000808fc3e590 00007ffe329daf27 (MethodDesc 00007ffe325d08a0 +0x47 System.Threading.Tasks.Task.Execute())
000000808fc3e5a0 00007ffe329db335 (MethodDesc 00007ffe325d0910 +0x15 System.Threading.Tasks.Task.ExecutionContextCallback(System.Object))
000000808fc3e5d0 00007ffe3296df12 (MethodDesc 00007ffe323e85b8 +0x172 System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean))
000000808fc3e5e0 00007ffe32946fbe (MethodDesc 00007ffe325d0a78 +0x47e System.Threading.Tasks.Task.FinishContinuations())
000000808fc3e6a0 00007ffe3296dd95 (MethodDesc 00007ffe325c87a0 +0x15 System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean))
000000808fc3e6d0 00007ffe329db1e1 (MethodDesc 00007ffe325d0cf8 +0x231 System.Threading.Tasks.Task.ExecuteWithThreadLocal(System.Threading.Tasks.Task ByRef))
000000808fc3e720 00007ffe32938c92 (MethodDesc 00007ffe326e6a58 +0x22 System.Threading.ThreadPoolWorkQueue.EnsureThreadRequested())
000000808fc3e780 00007ffe329da8c1 (MethodDesc 00007ffe325d0900 +0xa1 System.Threading.Tasks.Task.ExecuteEntry(Boolean))
000000808fc3e7c0 00007ffe32938e46 (MethodDesc 00007ffe326e6aa8 +0x156 System.Threading.ThreadPoolWorkQueue.Dispatch())

From the above stack trace, I suspected that the HashSet in trouble was still checking whether an element was inside it in Microsoft.CodeAnalysis.Diagnostics.AnalyzerExecutor.ExecuteSyntaxNodeActions, however, the same HashSet was Cleared by another thread, thus this thread ran into an infinite loop.

Please have this issue fixed.

Issue Analytics

  • State:closed
  • Created 10 months ago
  • Reactions:1
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
wmjordancommented, Nov 17, 2022

@pawchen I’ve hereby written a thing to monitor the system CPU usage merely for this bug. You can download the extension and turn on the CPU monitoring feature on VS.

0reactions
wmjordancommented, Nov 17, 2022

@sharwell

Yes, it is the issue. Sorry for having brought trouble to you. They said that issue had been fixed.

Read more comments on GitHub >

github_iconTop Results From Across the Web

ServiceHub.RoslynCodeAnalysisService.exe high CPU ...
For some reason, for some of my Visual Studio projects, the ServiceHub.RoslynCodeAnalysisService.exe is constantly using one whole CPU core.
Read more >
Memory leak in ServiceHub.RoslynCodeAnalysisService.exe
I'm constantly having to restart VisualStudio multiple times a day.
Read more >
Increase the chance of a performance issue being fixed
Each time Visual Studio crashes, it will create a dump file devenv.exe.[number].dmp file in the configured location. Then, use Visual ...
Read more >
Visual Studio 2019 Causing High CPU Usage during ...
I'm seeing one particular thread consistently using an entire core while debugging: "devenv.exe!WriteAssertEtwEventW+0x12e90".
Read more >
Visual Studio 2019 release. High CPU usage
When i load project to work on there is constantly about 30% of CPU is using on idle. Project is completely loaded, analyzed...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found