waf / CSharpRepl

A command line C# REPL with syntax highlighting – explore the language, libraries and nuget packages interactively.
https://fuqua.io/CSharpRepl/
Mozilla Public License 2.0
2.76k stars 106 forks source link

Crash on PropertySubpatternCompletionProvider #331

Closed ruby3141 closed 6 months ago

ruby3141 commented 6 months ago

Version

C# REPL 0.6.6+ba21d409af4dce77f8be07f6a61cdb24cd19bb29

What happened?

Accidentally triggered crash with typo, and successfully reproduced it on other machines. I think this one is the minimal input to reproduce crash.

> a is{a:1.

The content of trace file

2024-02-20T01:17:05 - Trace session starting
2024-02-20T01:17:05 - Starting background initialization
2024-02-20T01:17:05 - Discovered dotnet version .NET Core SDK 8.0.200 at C:\Program Files\dotnet\sdk\8.0.200.
2024-02-20T01:17:05 - Available Reference Assemblies: "C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref": ["6.0.27", "8.0.2"]
2024-02-20T01:17:05 - Available Implementation Assemblies: "C:\Program Files\dotnet\shared\Microsoft.NETCore.App": ["2.1.30", "2.1.9", "5.0.17", "6.0.27", "7.0.7", "8.0.2"]
2024-02-20T01:17:05 - .NET Version: Microsoft.NETCore.App / 8.0.2
2024-02-20T01:17:05 - Reference Assembly Paths: C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\8.0.2\ref\net8.0
2024-02-20T01:17:05 - Implementation Assembly Paths: C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.2
2024-02-20T01:17:05 - Shared Framework Paths: C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.2
2024-02-20T01:17:05 - Loaded Reference Assemblies: "C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\8.0.2\ref\net8.0": ["System.Threading.Channels.dll", "System.ComponentModel.Annotations.dll", "System.Net.NameResolution.dll", "System.Runtime.Serialization.Formatters.dll", "System.Security.Cryptography.X509Certificates.dll", "System.Threading.dll", "System.ComponentModel.DataAnnotations.dll", "System.Net.NetworkInformation.dll", "System.Runtime.Serialization.Json.dll", "System.Security.dll", "System.Threading.Overlapped.dll", "System.ComponentModel.dll", "System.Net.Ping.dll", "System.Runtime.Serialization.Primitives.dll", "System.Security.Principal.dll", "System.Threading.Tasks.Dataflow.dll", "System.ComponentModel.EventBasedAsync.dll", "System.Net.Primitives.dll", "System.Runtime.Serialization.Xml.dll", "System.Security.Principal.Windows.dll", "System.Threading.Tasks.dll", "System.ComponentModel.Primitives.dll", "System.Net.Quic.dll", "System.Security.AccessControl.dll", "System.Security.SecureString.dll", "System.Threading.Tasks.Extensions.dll", "System.ComponentModel.TypeConverter.dll", "System.Net.Requests.dll", "System.Security.Claims.dll", "System.ServiceModel.Web.dll", "System.Threading.Tasks.Parallel.dll", "System.Configuration.dll", "System.Net.Security.dll", "System.Security.Cryptography.Algorithms.dll", "System.ServiceProcess.dll", "System.Threading.Thread.dll", "System.Console.dll", "System.Net.ServicePoint.dll", "System.Security.Cryptography.Cng.dll", "System.Text.Encoding.CodePages.dll", "System.Threading.ThreadPool.dll", "System.Core.dll", "System.Net.Sockets.dll", "System.Security.Cryptography.Csp.dll", "System.Text.Encoding.dll", "System.Threading.Timer.dll", "System.Data.Common.dll", "System.Net.WebClient.dll", "System.Security.Cryptography.dll", "System.Text.Encoding.Extensions.dll", "System.Transactions.dll", "System.Data.DataSetExtensions.dll", "System.Net.WebHeaderCollection.dll", "System.Security.Cryptography.Encoding.dll", "System.Text.Encodings.Web.dll", "System.Transactions.Local.dll", "System.Data.dll", "System.Net.WebProxy.dll", "System.Security.Cryptography.OpenSsl.dll", "System.Text.Json.dll", "System.ValueTuple.dll", "System.Diagnostics.Contracts.dll", "System.Net.WebSockets.Client.dll", "System.Security.Cryptography.Primitives.dll", "System.Text.RegularExpressions.dll", "System.Diagnostics.Debug.dll", "System.Net.WebSockets.dll", "System.Globalization.Calendars.dll", "System.Globalization.dll", "System.Globalization.Extensions.dll", "System.IO.Compression.Brotli.dll", "System.IO.Compression.dll", "System.IO.Compression.FileSystem.dll", "System.IO.Compression.ZipFile.dll", "System.IO.dll", "System.IO.FileSystem.AccessControl.dll", "System.IO.FileSystem.dll", "System.IO.FileSystem.DriveInfo.dll", "System.IO.FileSystem.Primitives.dll", "System.IO.FileSystem.Watcher.dll", "System.IO.IsolatedStorage.dll", "System.Diagnostics.DiagnosticSource.dll", "System.Diagnostics.FileVersionInfo.dll", "System.Diagnostics.Process.dll", "System.Diagnostics.StackTrace.dll", "System.Diagnostics.TextWriterTraceListener.dll", "System.Diagnostics.Tools.dll", "System.Diagnostics.TraceSource.dll", "System.Diagnostics.Tracing.dll", "System.dll", "System.Drawing.dll", "System.Drawing.Primitives.dll", "System.Dynamic.Runtime.dll", "System.Formats.Asn1.dll", "System.Formats.Tar.dll", "System.Resources.Writer.dll", "System.Runtime.CompilerServices.Unsafe.dll", "System.Runtime.CompilerServices.VisualC.dll", "System.Runtime.dll", "System.Runtime.Extensions.dll", "System.Runtime.Handles.dll", "System.Runtime.InteropServices.dll", "System.Runtime.InteropServices.JavaScript.dll", "System.Runtime.InteropServices.RuntimeInformation.dll", "System.Runtime.Intrinsics.dll", "System.Runtime.Loader.dll", "System.Runtime.Numerics.dll", "System.Runtime.Serialization.dll", "Microsoft.CSharp.dll", "Microsoft.VisualBasic.Core.dll", "Microsoft.VisualBasic.dll", "Microsoft.Win32.Primitives.dll", "Microsoft.Win32.Registry.dll", "mscorlib.dll", "netstandard.dll", "System.AppContext.dll", "System.Buffers.dll", "System.Collections.Concurrent.dll", "System.Collections.dll", "System.Collections.Immutable.dll", "System.Collections.NonGeneric.dll", "System.Collections.Specialized.dll", "System.Numerics.dll", "System.Numerics.Vectors.dll", "System.ObjectModel.dll", "System.Reflection.DispatchProxy.dll", "System.Reflection.dll", "System.Reflection.Emit.dll", "System.Reflection.Emit.ILGeneration.dll", "System.Reflection.Emit.Lightweight.dll", "System.Reflection.Extensions.dll", "System.Reflection.Metadata.dll", "System.Reflection.Primitives.dll", "System.Reflection.TypeExtensions.dll", "System.Resources.Reader.dll", "System.Resources.ResourceManager.dll", "System.IO.MemoryMappedFiles.dll", "System.IO.Pipes.AccessControl.dll", "System.IO.Pipes.dll", "System.IO.UnmanagedMemoryStream.dll", "System.Linq.dll", "System.Linq.Expressions.dll", "System.Linq.Parallel.dll", "System.Linq.Queryable.dll", "System.Memory.dll", "System.Net.dll", "System.Net.Http.dll", "System.Net.Http.Json.dll", "System.Net.HttpListener.dll", "System.Net.Mail.dll", "System.Web.dll", "System.Web.HttpUtility.dll", "System.Windows.dll", "System.Xml.dll", "System.Xml.Linq.dll", "System.Xml.ReaderWriter.dll", "System.Xml.Serialization.dll", "System.Xml.XDocument.dll", "System.Xml.XmlDocument.dll", "System.Xml.XmlSerializer.dll", "System.Xml.XPath.dll", "System.Xml.XPath.XDocument.dll", "WindowsBase.dll"]
2024-02-20T01:17:05 - Loaded Implementation Assemblies: "C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.2": ["Microsoft.CSharp.dll", "Microsoft.VisualBasic.Core.dll", "Microsoft.VisualBasic.dll", "Microsoft.Win32.Primitives.dll", "Microsoft.Win32.Registry.dll", "mscorlib.dll", "System.Diagnostics.TraceSource.dll", "System.Diagnostics.Tracing.dll", "System.dll", "System.Drawing.dll", "System.Drawing.Primitives.dll", "System.Dynamic.Runtime.dll", "System.Formats.Asn1.dll", "System.Formats.Tar.dll", "System.Globalization.Calendars.dll", "System.Globalization.dll", "System.Globalization.Extensions.dll", "System.IO.Compression.Brotli.dll", "System.IO.Compression.dll", "System.IO.Compression.FileSystem.dll", "netstandard.dll", "System.AppContext.dll", "System.Buffers.dll", "System.Collections.Concurrent.dll", "System.Collections.dll", "System.Collections.Immutable.dll", "System.Collections.NonGeneric.dll", "System.Collections.Specialized.dll", "System.ComponentModel.Annotations.dll", "System.ComponentModel.DataAnnotations.dll", "System.ComponentModel.dll", "System.ComponentModel.EventBasedAsync.dll", "System.ComponentModel.Primitives.dll", "System.Reflection.dll", "System.Reflection.Emit.dll", "System.Reflection.Emit.ILGeneration.dll", "System.Reflection.Emit.Lightweight.dll", "System.Reflection.Extensions.dll", "System.Reflection.Metadata.dll", "System.Reflection.Primitives.dll", "System.Reflection.TypeExtensions.dll", "System.Resources.Reader.dll", "System.Resources.ResourceManager.dll", "System.Resources.Writer.dll", "System.Runtime.CompilerServices.Unsafe.dll", "System.Runtime.CompilerServices.VisualC.dll", "System.Runtime.dll", "System.Runtime.Extensions.dll", "System.Runtime.Handles.dll", "System.Runtime.InteropServices.dll", "System.Runtime.InteropServices.JavaScript.dll", "System.Runtime.InteropServices.RuntimeInformation.dll", "System.Runtime.Intrinsics.dll", "System.Runtime.Loader.dll", "System.Runtime.Numerics.dll", "System.Runtime.Serialization.dll", "System.Runtime.Serialization.Formatters.dll", "System.Runtime.Serialization.Json.dll", "System.Runtime.Serialization.Primitives.dll", "System.Runtime.Serialization.Xml.dll", "System.Security.AccessControl.dll", "System.Security.Claims.dll", "System.Security.Cryptography.Algorithms.dll", "System.Security.Cryptography.Cng.dll", "System.Security.Cryptography.Csp.dll", "System.Security.Cryptography.dll", "System.Security.Cryptography.Encoding.dll", "System.Security.Cryptography.OpenSsl.dll", "System.Security.Cryptography.Primitives.dll", "System.Security.Cryptography.X509Certificates.dll", "System.Security.dll", "System.Security.Principal.dll", "System.Security.Principal.Windows.dll", "System.Security.SecureString.dll", "System.ServiceModel.Web.dll", "System.ServiceProcess.dll", "System.Text.Encoding.CodePages.dll", "System.Text.Encoding.dll", "System.Text.Encoding.Extensions.dll", "System.Text.Encodings.Web.dll", "System.Text.Json.dll", "System.Text.RegularExpressions.dll", "System.Threading.Channels.dll", "System.Threading.dll", "System.Threading.Overlapped.dll", "System.Threading.Tasks.Dataflow.dll", "System.Threading.Tasks.dll", "System.Threading.Tasks.Extensions.dll", "System.Threading.Tasks.Parallel.dll", "System.Threading.Thread.dll", "System.Threading.ThreadPool.dll", "System.Threading.Timer.dll", "System.Transactions.dll", "System.ComponentModel.TypeConverter.dll", "System.Configuration.dll", "System.Console.dll", "System.Core.dll", "System.Data.Common.dll", "System.Data.DataSetExtensions.dll", "System.Data.dll", "System.Diagnostics.Contracts.dll", "System.Diagnostics.Debug.dll", "System.Diagnostics.DiagnosticSource.dll", "System.Diagnostics.FileVersionInfo.dll", "System.Diagnostics.Process.dll", "System.Diagnostics.StackTrace.dll", "System.Diagnostics.TextWriterTraceListener.dll", "System.Diagnostics.Tools.dll", "System.Linq.Queryable.dll", "System.Memory.dll", "System.Net.dll", "System.Net.Http.dll", "System.Net.Http.Json.dll", "System.Net.HttpListener.dll", "System.Net.Mail.dll", "System.Net.NameResolution.dll", "System.Net.NetworkInformation.dll", "System.Net.Ping.dll", "System.Net.Primitives.dll", "System.Net.Quic.dll", "System.Net.Requests.dll", "System.Net.Security.dll", "System.Net.ServicePoint.dll", "System.IO.Compression.ZipFile.dll", "System.IO.dll", "System.IO.FileSystem.AccessControl.dll", "System.IO.FileSystem.dll", "System.IO.FileSystem.DriveInfo.dll", "System.IO.FileSystem.Primitives.dll", "System.IO.FileSystem.Watcher.dll", "System.IO.IsolatedStorage.dll", "System.IO.MemoryMappedFiles.dll", "System.IO.Pipes.AccessControl.dll", "System.IO.Pipes.dll", "System.IO.UnmanagedMemoryStream.dll", "System.Linq.dll", "System.Linq.Expressions.dll", "System.Linq.Parallel.dll", "System.Transactions.Local.dll", "System.ValueTuple.dll", "System.Web.dll", "System.Web.HttpUtility.dll", "System.Windows.dll", "System.Xml.dll", "System.Xml.Linq.dll", "System.Xml.ReaderWriter.dll", "System.Xml.Serialization.dll", "System.Xml.XDocument.dll", "System.Xml.XmlDocument.dll", "System.Xml.XmlSerializer.dll", "System.Xml.XPath.dll", "System.Xml.XPath.XDocument.dll", "WindowsBase.dll", "System.Net.Sockets.dll", "System.Net.WebClient.dll", "System.Net.WebHeaderCollection.dll", "System.Net.WebProxy.dll", "System.Net.WebSockets.Client.dll", "System.Net.WebSockets.dll", "System.Numerics.dll", "System.Numerics.Vectors.dll", "System.ObjectModel.dll", "System.Private.CoreLib.dll", "System.Private.DataContractSerialization.dll", "System.Private.Uri.dll", "System.Private.Xml.dll", "System.Private.Xml.Linq.dll", "System.Reflection.DispatchProxy.dll"]
2024-02-20T01:17:05 - MEF Default Assemblies: C:\Users\ruby3141\.dotnet\tools\.store\csharprepl\0.6.6\csharprepl\0.6.6\tools\net8.0\any\Microsoft.CodeAnalysis.Workspaces.dll, C:\Users\ruby3141\.dotnet\tools\.store\csharprepl\0.6.6\csharprepl\0.6.6\tools\net8.0\any\Microsoft.CodeAnalysis.CSharp.Workspaces.dll, C:\Users\ruby3141\.dotnet\tools\.store\csharprepl\0.6.6\csharprepl\0.6.6\tools\net8.0\any\Microsoft.CodeAnalysis.Features.dll, C:\Users\ruby3141\.dotnet\tools\.store\csharprepl\0.6.6\csharprepl\0.6.6\tools\net8.0\any\Microsoft.CodeAnalysis.CSharp.Features.dll
2024-02-20T01:17:05 - Background initialization complete
2024-02-20T01:17:05 - Warm-up Starting
2024-02-20T01:17:07 - Warm-up Complete
2024-02-20T01:17:14 - Unhandled Exception: System.InvalidOperationException: This program location is thought to be unreachable. File='/_/src/Features/CSharp/Portable/Completion/CompletionProviders/PropertySubPatternCompletionProvider.cs' Line=116
   at Microsoft.CodeAnalysis.CSharp.Completion.Providers.PropertySubpatternCompletionProvider.<ProvideCompletionsAsync>g__GetMemberAccessType|3_1(ITypeSymbol type, ExpressionSyntax expression, Document document, SemanticModel semanticModel, Int32 position)
   at Microsoft.CodeAnalysis.CSharp.Completion.Providers.PropertySubpatternCompletionProvider.ProvideCompletionsAsync(CompletionContext context)
   at Microsoft.CodeAnalysis.Completion.CompletionService.GetContextAsync(CompletionProvider provider, Document document, Int32 position, CompletionTrigger triggerInfo, CompletionOptions options, TextSpan defaultSpan, SharedSyntaxContextsWithSpeculativeModel sharedContext, CancellationToken cancellationToken)
   at Microsoft.CodeAnalysis.Completion.CompletionService.ComputeNonEmptyCompletionContextsAsync(Document document, Int32 caretPosition, CompletionTrigger trigger, CompletionOptions options, TextSpan completionListSpan, ImmutableArray`1 providers, SharedSyntaxContextsWithSpeculativeModel sharedContext, CancellationToken cancellationToken)
   at Microsoft.CodeAnalysis.Completion.CompletionService.GetCompletionsAsync(Document document, Int32 caretPosition, CompletionOptions options, OptionSet passThroughOptions, CompletionTrigger trigger, ImmutableHashSet`1 roles, CancellationToken cancellationToken)
   at CSharpRepl.Services.Completion.AutoCompleteService.Complete(Document document, String text, Int32 caret) in /_/CSharpRepl.Services/Completion/AutoCompleteService.cs:line 47
   at CSharpRepl.Services.Roslyn.RoslynServices.CompleteAsync(String text, Int32 caret) in /_/CSharpRepl.Services/Roslyn/RoslynServices.cs:line 198
   at CSharpRepl.PrettyPromptConfig.CSharpReplPromptCallbacks.GetCompletionItemsAsync(String text, Int32 caret, TextSpan spanToBeReplaced, CancellationToken cancellationToken) in /_/CSharpRepl/CSharpReplPromptCallbacks.cs:line 95
   at PrettyPrompt.Panes.CompletionPane.PrettyPrompt.Consoles.IKeyPressHandler.OnKeyUp(KeyPress key, CancellationToken cancellationToken)
   at PrettyPrompt.Prompt.<>c__DisplayClass9_0.<<ReadLineAsync>g__InterpretKeyPress|0>d.MoveNext()
--- End of stack trace from previous location ---
   at PrettyPrompt.Prompt.ReadLineAsync()
   at CSharpRepl.ReadEvalPrintLoop.RunAsync(Configuration config) in /_/CSharpRepl/ReadEvalPrintLoop.cs:line 49
   at CSharpRepl.Program.Main(String[] args) in /_/CSharpRepl/Program.cs:line 68
   at CSharpRepl.Program.Main(String[] args) in /_/CSharpRepl/Program.cs:line 74
   at CSharpRepl.Program.<Main>(String[] args)
ruby3141 commented 6 months ago

Tested some more and made sure it's not about literal. I think the crash happens when provider is trying to access member information of an instance.