Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compiler error causes VS2017 to crash #3171

Closed
chillitom opened this issue Jun 1, 2017 · 9 comments
Closed

Compiler error causes VS2017 to crash #3171

chillitom opened this issue Jun 1, 2017 · 9 comments
Labels
Area-LangService-API Impact-High (Internal MS Team use only) Describes an issue with extreme impact on existing code. Regression
Milestone

Comments

@chillitom
Copy link
Contributor

chillitom commented Jun 1, 2017

Visual Studio crash caused by the F# compiler services.

I have a suspicion that it's related to fetch intellisense for a property on a type from another assembly (C#) where the property's type is in a third unreferenced assembly.

I'm running VS2017 with nighties. Initially saw the crash with a build from a few days ago, updated to test latest and still occuring, now running version 15.4.1.17060101

Stack trace:

   at Microsoft.FSharp.Compiler.ErrorLogger.ErrorLoggerExtensions.ErrorLogger.Error[b](ErrorLogger x, Exception exn)
   at Microsoft.FSharp.Compiler.Import.ImportTypeRefData(ImportMap env, range m, ILScopeRef scoref, String[] path, String typeName)
   at Microsoft.FSharp.Compiler.Import.ImportILTypeRefUncached(ImportMap env, range m, ILTypeRef tref)
   at Microsoft.FSharp.Compiler.Import.ImportILTypeRef(ImportMap env, range m, ILTypeRef tref)
   at Microsoft.FSharp.Compiler.Import.ImportILType(ImportMap env, range m, FSharpList`1 tinst, ILType typ)
   at [email protected](ILType ity)
   at Microsoft.FSharp.Primitives.Basics.List.choose[T,TResult](FSharpFunc`2 f, FSharpList`1 xs)
   at Microsoft.FSharp.Compiler.Infos.GetImmediateInterfacesOfType(SkipUnrefInterfaces skipUnref, TcGlobals g, ImportMap amap, range m, TType typ)
   at Microsoft.FSharp.Compiler.Infos.loop@162-45[a](Boolean followInterfaces, AllowMultiIntfInstantiations allowMultiIntfInst, SkipUnrefInterfaces skipUnref, FSharpFunc`2 visitor, TcGlobals g, ImportMap amap, range m, Int32 ndeep, TType typ, Tuple`3 tupledArg)
   at Microsoft.FSharp.Compiler.Infos.FoldHierarchyOfTypeAux[a](Boolean followInterfaces, AllowMultiIntfInstantiations allowMultiIntfInst, SkipUnrefInterfaces skipUnref, FSharpFunc`2 visitor, TcGlobals g, ImportMap amap, range m, TType typ, a acc)
   at Microsoft.FSharp.Compiler.InfoReader.InfoReader.GetIntrinsicRecdOrClassFieldInfosUncached[a](Tuple`2 _arg5, range m, TType typ)
   at [email protected](Tuple`3 tupledArg)
   at Microsoft.FSharp.Compiler.AbstractIL.Internal.Library.f@1-3[T,U](MemoizationTable`2 t, T x, Unit unitVar0)
   at Microsoft.FSharp.Compiler.AbstractIL.Internal.Library.MemoizationTable`2.Apply(T x)
   at Microsoft.FSharp.Compiler.NameResolution.ResolveCompletionsInType(NameResolver ncenv, NameResolutionEnv nenv, ResolveCompletionTargets completionTargets, range m, AccessorDomain ad, Boolean statics, TType typ)
   at Microsoft.FSharp.Compiler.NameResolution.ResolvePartialLongIdentInType(NameResolver ncenv, NameResolutionEnv nenv, ResolveCompletionTargets isApplicableMeth, range m, AccessorDomain ad, Boolean statics, FSharpList`1 plid, TType typ)
   at Microsoft.FSharp.Compiler.NameResolution.ResolvePartialLongIdentInType@3610-2.Invoke(PropInfo pinfo)
   at Microsoft.FSharp.Compiler.NameResolution.ResolvePartialLongIdentInType(NameResolver ncenv, NameResolutionEnv nenv, ResolveCompletionTargets isApplicableMeth, range m, AccessorDomain ad, Boolean statics, FSharpList`1 plid, TType typ)
   at Microsoft.FSharp.Compiler.NameResolution.ResolvePartialLongIdentPrim(NameResolver ncenv, NameResolutionEnv nenv, ResolveCompletionTargets isApplicableMeth, FullyQualifiedFlag fullyQualified, range m, AccessorDomain ad, FSharpList`1 plid, Boolean allowObsolete)
   at Microsoft.FSharp.Compiler.SourceCodeServices.TypeCheckInfo.GetEnvironmentLookupResolutions(NameResolutionEnv nenv, AccessorDomain ad, range m, FSharpList`1 plid, TypeNameResolutionFlag filterCtors, Boolean showObsolete)
   at Microsoft.FSharp.Compiler.SourceCodeServices.TypeCheckInfo.GetDeclaredItems[a](FSharpOption`1 parseResultsOpt, String lineStr, FSharpOption`1 origLongIdentOpt, Int32 colAtEndOfNamesAndResidue, FSharpOption`1 residueOpt, Int32 line, Int32 loc, TypeNameResolutionFlag filterCtors, ResolveOverloads resolveOverloads, FSharpFunc`2 hasTextChangedSinceLastTypecheck, Boolean isInRangeOperator, FSharpFunc`2 allSymbols)
   at Microsoft.FSharp.Compiler.SourceCodeServices.TypeCheckInfo.GetDeclItemsForNamesAtPosition(CompilationThreadToken ctok, FSharpOption`1 parseResultsOpt, FSharpOption`1 origLongIdentOpt, FSharpOption`1 residueOpt, Int32 line, String lineStr, Int32 colAtEndOfNamesAndResidue, TypeNameResolutionFlag filterCtors, ResolveOverloads resolveOverloads, FSharpFunc`2 getAllSymbols, FSharpFunc`2 hasTextChangedSinceLastTypecheck)
   at Microsoft.FSharp.Compiler.SourceCodeServices.TypeCheckInfo.GetSymbolUseAtLocation(CompilationThreadToken ctok, Int32 line, String lineStr, Int32 colAtEndOfNames, FSharpList`1 names)
   at <StartupCode$FSharp-Compiler-Private>[email protected](CompilationThreadToken ctok, TypeCheckInfo scope)
   at <StartupCode$FSharp-Compiler-Private>[email protected](CompilationThreadToken ctok)
   at <StartupCode$FSharp-Compiler-Private>[email protected](CompilationThreadToken ctok)
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.CodeAnalysis.Editor.Implementation.ReferenceHighlighting.ReferenceHighlightingViewTaggerProvider.<ProduceTagsAsync>d__12.MoveNext()
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.CodeAnalysis.Editor.Tagging.AbstractAsynchronousTaggerProvider`1.TagSource.<RecomputeTagsAsync>d__83.MoveNext()

Repro steps

See comment below

  • Operating system - Win7
  • VS2017
@chillitom
Copy link
Contributor Author

Attached is the most minimal reproduction i could find.

The case seems to be an F# lib taking a dependency on a C# type (class DirectDependency) in one assembly which itself has a property of type interface IIndirectDependency in a third assembly. This type IIndirectDependency extends a type in a missing assembly, in this case IJsonLineInfo from Newtonsoft.Json but probably not important what.

image

Continuing to type past this point e.g. dependency.Property.Crash will cause the compiler to error and visual studio to crash.

visualfsharp_bug_3171.zip

@forki
Copy link
Contributor

forki commented Jun 2, 2017

I can repro. I think it crashes somewhere in exceptionContinuation which was introduced by @dsyme in 6f5b2c4d

@forki
Copy link
Contributor

forki commented Jun 2, 2017

tcs.TrySetException(exn) crashes pretty hard and not even try catch around it can recover

@forki
Copy link
Contributor

forki commented Jun 2, 2017

image

@forki
Copy link
Contributor

forki commented Jun 2, 2017

#3174 fixes it for me

@chillitom
Copy link
Contributor Author

Good work! So quick.

I commented on the commit, might be nothing to worry about but could there still be race conditions?

@matthid
Copy link
Contributor

matthid commented Jun 2, 2017

@chillitom I'm not even sure there is a race there. In this line the registration has already been disposed and it should be garantueed that only a single continuation function is called.

@forki you test for tcs.Task.Status = TaskStatus.Running So I guess in this situation the task is already cancelled / errored? This is interesting, but I guess there is no easy way for me to get this into the debugger...
I speculate the runtime is just triggering the cancellation there and it can't handle when another cancellation is requested "within" the first

@forki
Copy link
Contributor

forki commented Jun 2, 2017

OK here is how I debugged it

  • buy/install windows and vs2017and all the other prerequisites
  • clone vf# repo
  • open vs2017 developer command prompt in administration mode
  • run "build.cmd debug vs"
  • open VF# solution in vs2017
  • filter in solution explorer for "opensouce" and set that project as startup project
  • F5
  • debug hive vs2017 should open
  • load the repro in debug hive
  • follow repro steps (I think you need to additionally save the file)
  • it should crash on the line I touched

@cartermp cartermp added Area-LangService-API Impact-High (Internal MS Team use only) Describes an issue with extreme impact on existing code. Regression labels Jun 2, 2017
@cartermp cartermp added this to the VS 2017 Updates milestone Jun 2, 2017
@dsyme
Copy link
Contributor

dsyme commented Jun 12, 2017

Closing as this has been fixed.

@dsyme dsyme closed this as completed Jun 12, 2017
@cartermp cartermp modified the milestones: VS 2017 Updates, 15.3 Jun 9, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-LangService-API Impact-High (Internal MS Team use only) Describes an issue with extreme impact on existing code. Regression
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants