roslyn: VBCSCompiler.exe hangs when building .Net Core 3 Preview 7 app from Visual Studio 16.3 Preview 1
Versions Used: Roslyn 3.3.0-beta1-19360-03 VS 2019 16.3.0 Preview 1 .Net Core 3.0.100-preview7-012821 OS: Windows 10 x64 1803
Actually, this issue started happening with VS 2019 16.2.0 Preview 1 at the end of May, back then I restored older version of Roslyn that came with VS 2019 16.1.0 (Net Core 3 Preview 5) to “fix” it, thinking newer previews will fix the issue. However, now it was announced that .Net Core 3 previews are aligned with VS, and the exact issue remains I decided to report it, as I can no longer continue using older Roslyn.
Steps to Reproduce:
- I initiate build of my project with Visual Studio, which ultimately runs:
"C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\Current\Bin\Roslyn\VBCSCompiler.exe" "-pipename:IVamwVzaBdrypv9GgVkRsjt1ff4WYeqbiBsnRMXwDlE"
- The process
VBCSCompiler.exe
ends up utilizing 100% CPU (1 thread) with the following stack trace:
0, ntoskrnl.exe!KeWaitForMutexObject+0x30c1
1, ntoskrnl.exe!KeWaitForMutexObject+0x1521
2, ntoskrnl.exe!KeWaitForMutexObject+0xadb
3, ntoskrnl.exe!KeWaitForMutexObject+0x1ff
4, ntoskrnl.exe!ExWaitForRundownProtectionRelease+0x9fa
5, ntoskrnl.exe!KeWaitForMutexObject+0x31cb
6, ntoskrnl.exe!KeSynchronizeExecution+0x2dec
7, Microsoft.CodeAnalysis.CSharp.Symbols.NamedTypeSymbol.EqualsComplicatedCases(Microsoft.CodeAnalysis.CSharp.Symbols.NamedTypeSymbol, Microsoft.CodeAnalysis.TypeCompareKind, System.Collections.Generic.IReadOnlyDictionary`2<Microsoft.CodeAnalysis.CSharp.Symbols.TypeParameterSymbol,Boolean>) + 0x12e <-- 0x7ffb65ee7bce
8, Microsoft.CodeAnalysis.CSharp.Symbols.TypeWithAnnotations+NonLazyType.TypeSymbolEquals(Microsoft.CodeAnalysis.CSharp.Symbols.TypeWithAnnotations, Microsoft.CodeAnalysis.CSharp.Symbols.TypeWithAnnotations, Microsoft.CodeAnalysis.TypeCompareKind, System.Collections.Generic.IReadOnlyDictionary`2<Microsoft.CodeAnalysis.CSharp.Symbols.TypeParameterSymbol,Boolean>) + 0x67 <-- 0x7ffb65f13497
9, Microsoft.CodeAnalysis.CSharp.Symbols.TypeWithAnnotations.Equals(Microsoft.CodeAnalysis.CSharp.Symbols.TypeWithAnnotations, Microsoft.CodeAnalysis.TypeCompareKind, System.Collections.Generic.IReadOnlyDictionary`2<Microsoft.CodeAnalysis.CSharp.Symbols.TypeParameterSymbol,Boolean>) + 0xbb <-- 0x7ffb65ee91db
10, Microsoft.CodeAnalysis.CSharp.Symbols.NamedTypeSymbol.EqualsComplicatedCases(Microsoft.CodeAnalysis.CSharp.Symbols.NamedTypeSymbol, Microsoft.CodeAnalysis.TypeCompareKind, System.Collections.Generic.IReadOnlyDictionary`2<Microsoft.CodeAnalysis.CSharp.Symbols.TypeParameterSymbol,Boolean>) + 0x190 <-- 0x7ffb65ee7c30
11, Microsoft.CodeAnalysis.CSharp.Symbols.TypeWithAnnotations.SubstituteTypeCore(Microsoft.CodeAnalysis.CSharp.Symbols.AbstractTypeMap, Boolean) + 0x145 <-- 0x7ffb65ee5b65
12, Microsoft.CodeAnalysis.CSharp.Symbols.TypeWithAnnotations+NonLazyType.SubstituteType(Microsoft.CodeAnalysis.CSharp.Symbols.TypeWithAnnotations, Microsoft.CodeAnalysis.CSharp.Symbols.AbstractTypeMap, Boolean) + 0x22 <-- 0x7ffb65ee5722
13, Microsoft.CodeAnalysis.CSharp.LambdaRewriter.SubstituteTypeArguments(System.Collections.Immutable.ImmutableArray`1<Microsoft.CodeAnalysis.CSharp.Symbols.TypeWithAnnotations>) + 0x122 <-- 0x7ffb669ffb02
14, Microsoft.CodeAnalysis.CSharp.LambdaRewriter.RemapLocalFunction(Microsoft.CodeAnalysis.SyntaxNode, Microsoft.CodeAnalysis.CSharp.Symbols.MethodSymbol, Microsoft.CodeAnalysis.CSharp.BoundExpression ByRef, Microsoft.CodeAnalysis.CSharp.Symbols.MethodSymbol ByRef, System.Collections.Immutable.ImmutableArray`1<Microsoft.CodeAnalysis.CSharp.BoundExpression> ByRef, System.Collections.Immutable.ImmutableArray`1<Microsoft.CodeAnalysis.RefKind> ByRef) + 0x575 <-- 0x7ffb669ff6c5
15, Microsoft.CodeAnalysis.CSharp.LambdaRewriter.VisitCall(Microsoft.CodeAnalysis.CSharp.BoundCall) + 0xbc <-- 0x7ffb6696929c
16, Microsoft.CodeAnalysis.CSharp.BoundTreeRewriterWithStackGuard.VisitExpressionWithoutStackGuard(Microsoft.CodeAnalysis.CSharp.BoundExpression) + 0x26 <-- 0x7ffb6652c0f6
17, Microsoft.CodeAnalysis.CSharp.BoundTreeVisitor.VisitExpressionWithStackGuard(Int32 ByRef, Microsoft.CodeAnalysis.CSharp.BoundExpression) + 0x44 <-- 0x7ffb65fdf614
18, Microsoft.CodeAnalysis.CSharp.BoundTreeRewriter.VisitReturnStatement(Microsoft.CodeAnalysis.CSharp.BoundReturnStatement) + 0x16 <-- 0x7ffb6652bf76
19, Microsoft.CodeAnalysis.CSharp.BoundTreeRewriterWithStackGuard.Visit(Microsoft.CodeAnalysis.CSharp.BoundNode) + 0x57 <-- 0x7ffb66924937
20, Microsoft.CodeAnalysis.CSharp.BoundTreeRewriter.VisitSequencePoint(Microsoft.CodeAnalysis.CSharp.BoundSequencePoint) + 0x16 <-- 0x7ffb66532aa6
21, Microsoft.CodeAnalysis.CSharp.LambdaRewriter.RewriteBlock(Microsoft.CodeAnalysis.CSharp.BoundBlock, Microsoft.CodeAnalysis.PooledObjects.ArrayBuilder`1<Microsoft.CodeAnalysis.CSharp.BoundExpression>, Microsoft.CodeAnalysis.PooledObjects.ArrayBuilder`1<Microsoft.CodeAnalysis.CSharp.Symbols.LocalSymbol>) + 0x14b <-- 0x7ffb669673bb
22, Microsoft.CodeAnalysis.CSharp.LambdaRewriter.VisitBlock(Microsoft.CodeAnalysis.CSharp.BoundBlock) + 0xeb <-- 0x7ffb6696675b
23, Microsoft.CodeAnalysis.CSharp.LambdaRewriter.RewriteLambdaOrLocalFunction(Microsoft.CodeAnalysis.CSharp.IBoundLambdaOrFunction, Microsoft.CodeAnalysis.CSharp.ClosureKind ByRef, Microsoft.CodeAnalysis.CSharp.Symbols.NamedTypeSymbol ByRef, Microsoft.CodeAnalysis.CSharp.SynthesizedClosureEnvironment ByRef, Microsoft.CodeAnalysis.CSharp.BoundNode ByRef, Microsoft.CodeAnalysis.CodeGen.DebugId ByRef, Microsoft.CodeAnalysis.CodeGen.DebugId ByRef) + 0x3d4 <-- 0x7ffb6696c014
24, Microsoft.CodeAnalysis.CSharp.LambdaRewriter.RewriteLambdaConversion(Microsoft.CodeAnalysis.CSharp.BoundLambda) + 0x19a <-- 0x7ffb6696acfa
25, Microsoft.CodeAnalysis.CSharp.LambdaRewriter.VisitConversion(Microsoft.CodeAnalysis.CSharp.BoundConversion) + 0x57 <-- 0x7ffb66969eb7
26, Microsoft.CodeAnalysis.CSharp.BoundTreeRewriterWithStackGuard.VisitExpressionWithoutStackGuard(Microsoft.CodeAnalysis.CSharp.BoundExpression) + 0x26 <-- 0x7ffb6652c0f6
27, Microsoft.CodeAnalysis.CSharp.BoundTreeVisitor.VisitExpressionWithStackGuard(Int32 ByRef, Microsoft.CodeAnalysis.CSharp.BoundExpression) + 0x44 <-- 0x7ffb65fdf614
28, Microsoft.CodeAnalysis.CSharp.BoundTreeRewriter.DoVisitList[[System.__Canon, mscorlib]](System.Collections.Immutable.ImmutableArray`1<System.__Canon>) + 0x40 <-- 0x7ffb665221c0
29, Microsoft.CodeAnalysis.CSharp.Symbols.MethodToClassRewriter.VisitCall(Microsoft.CodeAnalysis.CSharp.BoundCall) + 0x7e <-- 0x7ffb66956f0e
30, Microsoft.CodeAnalysis.CSharp.LambdaRewriter.VisitCall(Microsoft.CodeAnalysis.CSharp.BoundCall) + 0x13d <-- 0x7ffb6696931d
31, Microsoft.CodeAnalysis.CSharp.BoundTreeRewriterWithStackGuard.VisitExpressionWithoutStackGuard(Microsoft.CodeAnalysis.CSharp.BoundExpression) + 0x26 <-- 0x7ffb6652c0f6
32, Microsoft.CodeAnalysis.CSharp.BoundTreeVisitor.VisitExpressionWithStackGuard(Int32 ByRef, Microsoft.CodeAnalysis.CSharp.BoundExpression) + 0x44 <-- 0x7ffb65fdf614
33, Microsoft.CodeAnalysis.CSharp.BoundTreeRewriter.DoVisitList[[System.__Canon, mscorlib]](System.Collections.Immutable.ImmutableArray`1<System.__Canon>) + 0x40 <-- 0x7ffb665221c0
34, Microsoft.CodeAnalysis.CSharp.Symbols.MethodToClassRewriter.VisitCall(Microsoft.CodeAnalysis.CSharp.BoundCall) + 0x7e <-- 0x7ffb66956f0e
35, Microsoft.CodeAnalysis.CSharp.LambdaRewriter.VisitCall(Microsoft.CodeAnalysis.CSharp.BoundCall) + 0x13d <-- 0x7ffb6696931d
36, Microsoft.CodeAnalysis.CSharp.BoundTreeRewriterWithStackGuard.VisitExpressionWithoutStackGuard(Microsoft.CodeAnalysis.CSharp.BoundExpression) + 0x26 <-- 0x7ffb6652c0f6
37, Microsoft.CodeAnalysis.CSharp.BoundTreeVisitor.VisitExpressionWithStackGuard(Microsoft.CodeAnalysis.CSharp.BoundExpression) + 0x22 <-- 0x7ffb66514462
38, Microsoft.CodeAnalysis.CSharp.BoundTreeVisitor.VisitExpressionWithStackGuard(Int32 ByRef, Microsoft.CodeAnalysis.CSharp.BoundExpression) + 0x51 <-- 0x7ffb65fdf621
39, Microsoft.CodeAnalysis.CSharp.BoundTreeRewriter.VisitReturnStatement(Microsoft.CodeAnalysis.CSharp.BoundReturnStatement) + 0x16 <-- 0x7ffb6652bf76
40, Microsoft.CodeAnalysis.CSharp.BoundTreeRewriterWithStackGuard.Visit(Microsoft.CodeAnalysis.CSharp.BoundNode) + 0x57 <-- 0x7ffb66924937
41, Microsoft.CodeAnalysis.CSharp.BoundTreeRewriter.VisitSequencePoint(Microsoft.CodeAnalysis.CSharp.BoundSequencePoint) + 0x16 <-- 0x7ffb66532aa6
42, Microsoft.CodeAnalysis.CSharp.LambdaRewriter.RewriteBlock(Microsoft.CodeAnalysis.CSharp.BoundBlock, Microsoft.CodeAnalysis.PooledObjects.ArrayBuilder`1<Microsoft.CodeAnalysis.CSharp.BoundExpression>, Microsoft.CodeAnalysis.PooledObjects.ArrayBuilder`1<Microsoft.CodeAnalysis.CSharp.Symbols.LocalSymbol>) + 0x14b <-- 0x7ffb669673bb
43, Microsoft.CodeAnalysis.CSharp.LambdaRewriter.IntroduceFrame(Microsoft.CodeAnalysis.CSharp.BoundNode, ClosureEnvironment, System.Func`3<Microsoft.CodeAnalysis.PooledObjects.ArrayBuilder`1<Microsoft.CodeAnalysis.CSharp.BoundExpression>,Microsoft.CodeAnalysis.PooledObjects.ArrayBuilder`1<Microsoft.CodeAnalysis.CSharp.Symbols.LocalSymbol>,Microsoft.CodeAnalysis.CSharp.BoundNode>) + 0x855 <-- 0x7ffb669689c5
44, Microsoft.CodeAnalysis.CSharp.LambdaRewriter.VisitBlock(Microsoft.CodeAnalysis.CSharp.BoundBlock) + 0x9f <-- 0x7ffb6696670f
45, Microsoft.CodeAnalysis.CSharp.BoundTreeRewriterWithStackGuard.Visit(Microsoft.CodeAnalysis.CSharp.BoundNode) + 0x57 <-- 0x7ffb66924937
46, Microsoft.CodeAnalysis.CSharp.LambdaRewriter.Rewrite(Microsoft.CodeAnalysis.CSharp.BoundStatement, Microsoft.CodeAnalysis.CSharp.Symbols.NamedTypeSymbol, Microsoft.CodeAnalysis.CSharp.Symbols.ParameterSymbol, Microsoft.CodeAnalysis.CSharp.Symbols.MethodSymbol, Int32, Microsoft.CodeAnalysis.CSharp.Symbols.MethodSymbol, Microsoft.CodeAnalysis.PooledObjects.ArrayBuilder`1<Microsoft.CodeAnalysis.CodeGen.LambdaDebugInfo>, Microsoft.CodeAnalysis.PooledObjects.ArrayBuilder`1<Microsoft.CodeAnalysis.CodeGen.ClosureDebugInfo>, Microsoft.CodeAnalysis.CodeGen.VariableSlotAllocator, Microsoft.CodeAnalysis.CSharp.TypeCompilationState, Microsoft.CodeAnalysis.DiagnosticBag, System.Collections.Generic.HashSet`1<Microsoft.CodeAnalysis.CSharp.Symbols.LocalSymbol>) + 0xf2 <-- 0x7ffb66934b82
47, Microsoft.CodeAnalysis.CSharp.MethodCompiler.LowerBodyOrInitializer(Microsoft.CodeAnalysis.CSharp.Symbols.MethodSymbol, Int32, Microsoft.CodeAnalysis.CSharp.BoundStatement, Microsoft.CodeAnalysis.CSharp.SynthesizedSubmissionFields, Microsoft.CodeAnalysis.CSharp.TypeCompilationState, Boolean, Microsoft.CodeAnalysis.CodeGen.DebugDocumentProvider, System.Collections.Immutable.ImmutableArray`1<Microsoft.CodeAnalysis.CodeGen.SourceSpan> ByRef, Microsoft.CodeAnalysis.DiagnosticBag, Microsoft.CodeAnalysis.CodeGen.VariableSlotAllocator ByRef, Microsoft.CodeAnalysis.PooledObjects.ArrayBuilder`1<Microsoft.CodeAnalysis.CodeGen.LambdaDebugInfo>, Microsoft.CodeAnalysis.PooledObjects.ArrayBuilder`1<Microsoft.CodeAnalysis.CodeGen.ClosureDebugInfo>, Microsoft.CodeAnalysis.CSharp.StateMachineTypeSymbol ByRef) + 0x1ec <-- 0x7ffb6652a95c
48, Microsoft.CodeAnalysis.CSharp.MethodCompiler.CompileMethod(Microsoft.CodeAnalysis.CSharp.Symbols.MethodSymbol, Int32, ProcessedFieldInitializers ByRef, Microsoft.CodeAnalysis.CSharp.SynthesizedSubmissionFields, Microsoft.CodeAnalysis.CSharp.TypeCompilationState) + 0x9f8 <-- 0x7ffb665118f8
49, Microsoft.CodeAnalysis.CSharp.MethodCompiler.CompileNamedType(Microsoft.CodeAnalysis.CSharp.Symbols.NamedTypeSymbol) + 0x585 <-- 0x7ffb6650d995
50, Microsoft.CodeAnalysis.CSharp.MethodCompiler+<>c__DisplayClass22_0.<CompileNamedTypeAsTask>b__0() + 0x23 <-- 0x7ffb6650ce43
51, Roslyn.Utilities.UICultureUtilities+<>c__DisplayClass5_0.<WithCurrentUICulture>b__0() + 0x6e <-- 0x7ffb664a293e
52, System.Threading.Tasks.Task.Execute() + 0x47 <-- mscorlib.ni.dll+0x5f9d47
53, System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean) + 0x172 <-- mscorlib.ni.dll+0x58cef2
54, System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean) + 0x15 <-- mscorlib.ni.dll+0x58cd75
55, System.Threading.Tasks.Task.ExecuteWithThreadLocal(System.Threading.Tasks.Task ByRef) + 0x231 <-- mscorlib.ni.dll+0x5fa001
56, System.Threading.Tasks.Task.ExecuteEntry(Boolean) + 0xa1 <-- mscorlib.ni.dll+0x5f96e1
57, System.Threading.ThreadPoolWorkQueue.Dispatch() + 0x156 <-- mscorlib.ni.dll+0x557e46
58, clr.dll!LogHelp_LogAssert+0x1f13
59, clr.dll!LogHelp_LogAssert+0x1df9
60, clr.dll!LogHelp_LogAssert+0x2690
61, clr.dll!LogHelp_LogAssert+0x740a
62, clr.dll!LogHelp_LogAssert+0x3540
63, clr.dll!LogHelp_LogAssert+0x34b3
64, clr.dll!LogHelp_LogAssert+0x33f2
65, clr.dll!LogHelp_LogAssert+0x35cf
66, clr.dll!LogHelp_LogAssert+0x7357
67, clr.dll!LogHelp_LogAssert+0x3107
68, clr.dll!LogHelp_LogAssert+0x2fdf
69, clr.dll!LogHelp_LogAssert+0x68c5
70, kernel32.dll!BaseThreadInitThunk+0x14
71, ntdll.dll!RtlUserThreadStart+0x21
- The compilation never finishes. I don;t know exactly what code causes it to hang and why. Simple Hello World console app compiles without problems.
I also notice that Roslyn files in C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\Current\Bin\Roslyn
and C:\Program Files\dotnet\sdk\3.0.100-preview7-012821\Roslyn\bincore
are very different size-wise despite having almost identical versions.
Expected Behavior:
Projects compile without compiler hanging.
Actual Behavior:
Compiler hangs, compilation never finishes.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 20 (11 by maintainers)
Fix merged for 16.3p2. We’re discussing porting it back to a servicing fix for 16.2.
16.2.2 and 16.3 prev 2 still do not contain the fix? Can you explain why?
Thanks @RikkiGibson. Could you assist in adding this to Known Issues in 16.2? See this feedback where I’ve added a comment. It could potentially prevent other developers from wasting time on this issue.
So, just came back after vacation and happily upgraded to 16.2. Our application wouldn’t compile anymore. Spent the entire day searching for a solution until I stumbled upon this issue, which I now through a dump have confirmed is the culprit. (it will never leave the while loop…)
What’s my options now? Uninstall 16.2 and install 16.1? Seems like 16.3p2 is not available anywhere yet.
@HNordhaus @agocke with 16.2.3 and 2.2.401 SDK it seems possible to build using the IDE without the
Microsoft.Net.Compilers.Toolset
workaround. However, alldotnet
CLI commands still hang the compiler, such asdotnet ef migrations add
that force a build before adding a migration. I had to manually add aglobal.json
file with an old SDK version such as 2.2.300 to work around this problem until a newer SDK version is released with the fix.@HNordhaus I just tried this in 16.2 and it looks like the reported bug (the code above) is fixed. Can you try with the repro code above and see if the issue reproduces? If it doesn’t, you may be hitting a different bug.
@HNordhaus
Sorry that this bug has had such a negative impact on your team. The fix has been merged into our serving branches and should appear in the next servicing update to 16.2.
In the mean time you can do the following to any projects affected by this bug. Or if you use Directory.Build.props you can add the work around there and it will patch the compiler for all the projects:
<PackageReference Include="Microsoft.Net.Compilers.Toolset" Version="3.3.0-beta3-19407-05" />
Once the 16.2 servicing fix is out you should undo these changes so that you go back to the standard compiler.
@jcemoller I tagged the feedback item as a known issue. Thanks.
@fitdev, thanks for the repro! The issue repros with
csc.exe Program.cs
.It looks like
LambdaRewriter.SubstituteTypeArguments
is not completing.