{"action":"opened","issue":{"url":"https://api.github.com/repos/dotnet/roslyn/issues/25991","repository_url":"https://api.github.com/repos/dotnet/roslyn","labels_url":"https://api.github.com/repos/dotnet/roslyn/issues/25991/labels{/name}","comments_url":"https://api.github.com/repos/dotnet/roslyn/issues/25991/comments","events_url":"https://api.github.com/repos/dotnet/roslyn/issues/25991/events","html_url":"https://github.com/dotnet/roslyn/issues/25991","id":311937464,"number":25991,"title":"Compiler crash csc.exe","user":{"login":"rvhelden","id":4113326,"avatar_url":"https://avatars1.githubusercontent.com/u/4113326?v=4","gravatar_id":"","url":"https://api.github.com/users/rvhelden","html_url":"https://github.com/rvhelden","followers_url":"https://api.github.com/users/rvhelden/followers","following_url":"https://api.github.com/users/rvhelden/following{/other_user}","gists_url":"https://api.github.com/users/rvhelden/gists{/gist_id}","starred_url":"https://api.github.com/users/rvhelden/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rvhelden/subscriptions","organizations_url":"https://api.github.com/users/rvhelden/orgs","repos_url":"https://api.github.com/users/rvhelden/repos","events_url":"https://api.github.com/users/rvhelden/events{/privacy}","received_events_url":"https://api.github.com/users/rvhelden/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-04-06T11:14:33Z","updated_at":"2018-04-06T11:14:33Z","closed_at":null,"author_association":"NONE","body":"The compiler crashes with an unknown hard error and with exit code -2146232797\r\nWhen compiling the following class\r\n\r\n   ```\r\npublic class CrashClass\r\n{\r\n    public async Task OnCrash()\r\n    {\r\n        var switchObject = new object();\r\n        switch (switchObject)\r\n        {\r\n            case InvalidCastException _:\r\n                switch (switchObject)\r\n                {\r\n                    case NullReferenceException exception:\r\n\r\n                        await Task.CompletedTask;\r\n\r\n                        var myexception = exception;\r\n                        break;\r\n                }\r\n                break;\r\n            case InvalidOperationException _:\r\n                switch (switchObject)\r\n                {\r\n                    case NullReferenceException exception:\r\n\r\n                        await Task.CompletedTask;\r\n\r\n                        var myexception = exception;\r\n                        break;\r\n                }\r\n\r\n                break;\r\n\r\n        }\r\n    }\r\n}\r\n```\r\nThis is the stacktrace I got\r\n\r\n> Application: csc.exe\r\n> Framework Version: v4.0.30319\r\n> Description: The application requested process termination through System.Environment.FailFast(string message).\r\n> Message: System.IndexOutOfRangeException: Index was outside the bounds of the array.\r\n>    at System.Collections.Immutable.ImmutableArray`1.Builder.set_Item(Int32 index, T value)\r\n>    at Microsoft.CodeAnalysis.CodeGen.ILBuilder.LocalScopeInfo.GetHoistedLocalScopes(ArrayBuilder`1 result)\r\n>    at Microsoft.CodeAnalysis.CodeGen.ILBuilder.ScopeInfo.GetHoistedLocalScopes[TScopeInfo](ArrayBuilder`1 result, Builder scopes)\r\n>    at Microsoft.CodeAnalysis.CodeGen.ILBuilder.LocalScopeInfo.GetHoistedLocalScopes(ArrayBuilder`1 result)\r\n>    at Microsoft.CodeAnalysis.CodeGen.ILBuilder.ScopeInfo.GetHoistedLocalScopes[TScopeInfo](ArrayBuilder`1 result, Builder scopes)\r\n>    at Microsoft.CodeAnalysis.CodeGen.ILBuilder.LocalScopeInfo.GetHoistedLocalScopes(ArrayBuilder`1 result)\r\n>    at Microsoft.CodeAnalysis.CodeGen.ILBuilder.ScopeInfo.GetHoistedLocalScopes[TScopeInfo](ArrayBuilder`1 result, Builder scopes)\r\n>    at Microsoft.CodeAnalysis.CodeGen.ILBuilder.LocalScopeInfo.GetHoistedLocalScopes(ArrayBuilder`1 result)\r\n>    at Microsoft.CodeAnalysis.CodeGen.ILBuilder.ScopeInfo.GetHoistedLocalScopes[TScopeInfo](ArrayBuilder`1 result, Builder scopes)\r\n>    at Microsoft.CodeAnalysis.CodeGen.ILBuilder.ScopeInfo.GetHoistedLocalScopes[TScopeInfo](ArrayBuilder`1 result, Builder scopes)\r\n>    at Microsoft.CodeAnalysis.CodeGen.ILBuilder.LocalScopeInfo.GetHoistedLocalScopes(ArrayBuilder`1 result)\r\n>    at Microsoft.CodeAnalysis.CodeGen.ILBuilder.ScopeInfo.GetHoistedLocalScopes[TScopeInfo](ArrayBuilder`1 result, Builder scopes)\r\n>    at Microsoft.CodeAnalysis.CodeGen.ILBuilder.LocalScopeInfo.GetHoistedLocalScopes(ArrayBuilder`1 result)\r\n>    at Microsoft.CodeAnalysis.CodeGen.ILBuilder.ScopeInfo.GetHoistedLocalScopes[TScopeInfo](ArrayBuilder`1 result, Builder scopes)\r\n>    at Microsoft.CodeAnalysis.CodeGen.ILBuilder.LocalScopeInfo.GetHoistedLocalScopes(ArrayBuilder`1 result)\r\n>    at Microsoft.CodeAnalysis.CodeGen.ILBuilder.LocalScopeManager.GetHoistedLocalScopes()\r\n>    at Microsoft.CodeAnalysis.CSharp.MethodCompiler.GenerateMethodBody(PEModuleBuilder moduleBuilder, MethodSymbol method, Int32 methodOrdinal, BoundStatement block, ImmutableArray`1 lambdaDebugInfo, ImmutableArray`1 closureDebugInfo, StateMachineTypeSymbol stateMachineTypeOpt, VariableSlotAllocator variableSlotAllocatorOpt, DiagnosticBag diagnostics, DebugDocumentProvider debugDocumentProvider, ImportChain importChainOpt, Boolean emittingPdb, Boolean emitTestCoverageData, ImmutableArray`1 dynamicAnalysisSpans)\r\n>    at Microsoft.CodeAnalysis.CSharp.MethodCompiler.CompileSynthesizedMethods(TypeCompilationState compilationState)\r\n>    at Microsoft.CodeAnalysis.CSharp.MethodCompiler.CompileNamedType(NamedTypeSymbol containingType)\r\n>    at Microsoft.CodeAnalysis.CSharp.MethodCompiler.<>c__DisplayClass21_0.<CompileNamedTypeAsTask>b__0()\r\n> Stack:\r\n>    at System.Environment.FailFast(System.String, System.Exception)\r\n>    at Microsoft.CodeAnalysis.FatalError.Report(System.Exception, System.Action`1<System.Exception>)\r\n>    at Microsoft.CodeAnalysis.FatalError.ReportUnlessCanceled(System.Exception)\r\n>    at Microsoft.CodeAnalysis.CSharp.MethodCompiler+<>c__DisplayClass21_0.<CompileNamedTypeAsTask>b__0()\r\n>    at System.Collections.Immutable.ImmutableArray`1+Builder[[Microsoft.CodeAnalysis.Debugging.StateMachineHoistedLocalScope, Microsoft.CodeAnalysis, Version=2.7.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]].set_Item(Int32, Microsoft.CodeAnalysis.Debugging.StateMachineHoistedLocalScope)\r\n>    at Microsoft.CodeAnalysis.CodeGen.ILBuilder+LocalScopeInfo.GetHoistedLocalScopes(Microsoft.CodeAnalysis.PooledObjects.ArrayBuilder`1<Microsoft.CodeAnalysis.Debugging.StateMachineHoistedLocalScope>)\r\n>    at Microsoft.CodeAnalysis.CodeGen.ILBuilder+ScopeInfo.GetHoistedLocalScopes[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]](Microsoft.CodeAnalysis.PooledObjects.ArrayBuilder`1<Microsoft.CodeAnalysis.Debugging.StateMachineHoistedLocalScope>, Builder<System.__Canon>)\r\n>    at Microsoft.CodeAnalysis.CodeGen.ILBuilder+LocalScopeInfo.GetHoistedLocalScopes(Microsoft.CodeAnalysis.PooledObjects.ArrayBuilder`1<Microsoft.CodeAnalysis.Debugging.StateMachineHoistedLocalScope>)\r\n>    at Microsoft.CodeAnalysis.CodeGen.ILBuilder+ScopeInfo.GetHoistedLocalScopes[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]](Microsoft.CodeAnalysis.PooledObjects.ArrayBuilder`1<Microsoft.CodeAnalysis.Debugging.StateMachineHoistedLocalScope>, Builder<System.__Canon>)\r\n>    at Microsoft.CodeAnalysis.CodeGen.ILBuilder+LocalScopeInfo.GetHoistedLocalScopes(Microsoft.CodeAnalysis.PooledObjects.ArrayBuilder`1<Microsoft.CodeAnalysis.Debugging.StateMachineHoistedLocalScope>)\r\n>    at Microsoft.CodeAnalysis.CodeGen.ILBuilder+ScopeInfo.GetHoistedLocalScopes[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]](Microsoft.CodeAnalysis.PooledObjects.ArrayBuilder`1<Microsoft.CodeAnalysis.Debugging.StateMachineHoistedLocalScope>, Builder<System.__Canon>)\r\n>    at Microsoft.CodeAnalysis.CodeGen.ILBuilder+LocalScopeInfo.GetHoistedLocalScopes(Microsoft.CodeAnalysis.PooledObjects.ArrayBuilder`1<Microsoft.CodeAnalysis.Debugging.StateMachineHoistedLocalScope>)\r\n>    at Microsoft.CodeAnalysis.CodeGen.ILBuilder+ScopeInfo.GetHoistedLocalScopes[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]](Microsoft.CodeAnalysis.PooledObjects.ArrayBuilder`1<Microsoft.CodeAnalysis.Debugging.StateMachineHoistedLocalScope>, Builder<System.__Canon>)\r\n>    at Microsoft.CodeAnalysis.CodeGen.ILBuilder+ScopeInfo.GetHoistedLocalScopes[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]](Microsoft.CodeAnalysis.PooledObjects.ArrayBuilder`1<Microsoft.CodeAnalysis.Debugging.StateMachineHoistedLocalScope>, Builder<System.__Canon>)\r\n>    at Microsoft.CodeAnalysis.CodeGen.ILBuilder+LocalScopeInfo.GetHoistedLocalScopes(Microsoft.CodeAnalysis.PooledObjects.ArrayBuilder`1<Microsoft.CodeAnalysis.Debugging.StateMachineHoistedLocalScope>)\r\n>    at Microsoft.CodeAnalysis.CodeGen.ILBuilder+ScopeInfo.GetHoistedLocalScopes[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]](Microsoft.CodeAnalysis.PooledObjects.ArrayBuilder`1<Microsoft.CodeAnalysis.Debugging.StateMachineHoistedLocalScope>, Builder<System.__Canon>)\r\n>    at Microsoft.CodeAnalysis.CodeGen.ILBuilder+LocalScopeInfo.GetHoistedLocalScopes(Microsoft.CodeAnalysis.PooledObjects.ArrayBuilder`1<Microsoft.CodeAnalysis.Debugging.StateMachineHoistedLocalScope>)\r\n>    at Microsoft.CodeAnalysis.CodeGen.ILBuilder+ScopeInfo.GetHoistedLocalScopes[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]](Microsoft.CodeAnalysis.PooledObjects.ArrayBuilder`1<Microsoft.CodeAnalysis.Debugging.StateMachineHoistedLocalScope>, Builder<System.__Canon>)\r\n>    at Microsoft.CodeAnalysis.CodeGen.ILBuilder+LocalScopeInfo.GetHoistedLocalScopes(Microsoft.CodeAnalysis.PooledObjects.ArrayBuilder`1<Microsoft.CodeAnalysis.Debugging.StateMachineHoistedLocalScope>)\r\n>    at Microsoft.CodeAnalysis.CodeGen.ILBuilder+LocalScopeManager.GetHoistedLocalScopes()\r\n>    at Microsoft.CodeAnalysis.CSharp.MethodCompiler.GenerateMethodBody(Microsoft.CodeAnalysis.CSharp.Emit.PEModuleBuilder, Microsoft.CodeAnalysis.CSharp.Symbols.MethodSymbol, Int32, Microsoft.CodeAnalysis.CSharp.BoundStatement, System.Collections.Immutable.ImmutableArray`1<Microsoft.CodeAnalysis.CodeGen.LambdaDebugInfo>, System.Collections.Immutable.ImmutableArray`1<Microsoft.CodeAnalysis.CodeGen.ClosureDebugInfo>, Microsoft.CodeAnalysis.CSharp.StateMachineTypeSymbol, Microsoft.CodeAnalysis.CodeGen.VariableSlotAllocator, Microsoft.CodeAnalysis.DiagnosticBag, Microsoft.CodeAnalysis.CodeGen.DebugDocumentProvider, Microsoft.CodeAnalysis.CSharp.ImportChain, Boolean, Boolean, System.Collections.Immutable.ImmutableArray`1<Microsoft.CodeAnalysis.CodeGen.SourceSpan>)\r\n>    at Microsoft.CodeAnalysis.CSharp.MethodCompiler.CompileSynthesizedMethods(Microsoft.CodeAnalysis.CSharp.TypeCompilationState)\r\n>    at Microsoft.CodeAnalysis.CSharp.MethodCompiler.CompileNamedType(Microsoft.CodeAnalysis.CSharp.Symbols.NamedTypeSymbol)\r\n>    at Microsoft.CodeAnalysis.CSharp.MethodCompiler+<>c__DisplayClass21_0.<CompileNamedTypeAsTask>b__0()\r\n>    at Roslyn.Utilities.UICultureUtilities+<>c__DisplayClass5_0.<WithCurrentUICulture>b__0()\r\n>    at System.Threading.Tasks.Task.Execute()\r\n>    at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)\r\n>    at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)\r\n>    at System.Threading.Tasks.Task.ExecuteWithThreadLocal(System.Threading.Tasks.Task ByRef)\r\n>    at System.Threading.Tasks.Task.ExecuteEntry(Boolean)\r\n>    at System.Threading.ThreadPoolWorkQueue.Dispatch()\r\n> \r\n\r\n**Version Used**: \r\nMicrosoft Visual Studio 2017 15.6.4 and 15.6.5\r\n\r\n**Steps to Reproduce**:\r\n\r\n1. Compile in Release mode\r\n\r\n**Expected Behavior**:\r\nExpected a successfully compiled program\r\n\r\n**Actual Behavior**:\r\nCrashes with an hard error and exitcode -2146232797\r\n\r\n\r\nI have created a repository that is reproducing the issue here https://github.com/rvhelden/CompilerCrash\r\n\r\nThe history of this issue can be found here https://github.com/dotnet/roslyn/issues/25571\r\n\r\n@svick found this commit https://github.com/dotnet/roslyn/pull/23930 in the master branch that causes the compiler not to crash in the master branch but he suspects that the commit does not fix the issue but only hides the error"}}
{"actor":{"display_login":"rvhelden"}}