build.cmd vs current masterVisualFSharpOpenSource.vsix
I'm having similar issues


cc @brettfo
I've been looking at this one recently and it appears that the resolution of the FSharp.Core assembly is falling back to the one that was built locally with .\build.cmd vs due to rules that I don't fully understand. I've traced it back to here, but I've been unable to debug it so far.
I'll keep digging.
I've tested current master and it works on FSharp.Editor project, but does not on FCS and other 'core' projects.
Now it does not work even on FSharp.Editor project. The following assert error appears each time I open a file:
Assertion Failed: Abort=Quit, Retry=Debug, Ignore=Continue
Bug seen in compiler: Microsoft.FSharp.Compiler.ErrorLogger+InternalError: Exception of type 'Microsoft.FSharp.Compiler.ErrorLogger+InternalError' was thrown.
at Microsoft.FSharp.Compiler.CompileOps.[email protected](StringBuilder os, Exception _arg1)
at Microsoft.FSharp.Compiler.CompileOps.OutputPhasedErrorR(ErrorStyle errorStyle, StringBuilder os, PhasedDiagnostic err)
at Microsoft.FSharp.Compiler.CompileOps.OutputPhasedDiagnostic(ErrorStyle errorStyle, StringBuilder os, PhasedDiagnostic err, Boolean isError)
at
at Microsoft.FSharp.Compiler.Lib.bufs(FSharpFunc`2 f)
at Microsoft.FSharp.Compiler.FSharpErrorInfo.CreateFromException(PhasedDiagnostic exn, Boolean isError, Boolean trim, range fallbackRange)
at
at Microsoft.FSharp.Compiler.ErrorLogger.ErrorLoggerExtensions.ErrorLogger.Errorb
at Microsoft.FSharp.Compiler.CompileOps.TcImports.BuildFrameworkTcImports(TcConfigProvider tcConfigP, FSharpList1 frameworkDLLs, FSharpList1 nonFrameworkDLLs)
at Microsoft.FSharp.Compiler.FrameworkImportsCache.Get(TcConfig tcConfig)
at Microsoft.FSharp.Compiler.IncrementalBuilder..ctor(FrameworkImportsCache frameworkTcImportsCache, TcConfig tcConfig, String projectDirectory, String outfile, String assemblyName, NiceNameGenerator niceNameGen, LexResourceManager lexResourceManager, FSharpList1 sourceFiles, FSharpList1 projectReferences, FSharpOption`1 loadClosureOpt, Boolean ensureReactive, Boolean keepAssemblyContents, Boolean keepAllBackgroundResolutions)
at Microsoft.FSharp.Compiler.IncrementalBuilder.TryCreateBackgroundBuilderForProjectOptions(Resolver referenceResolver, FrameworkImportsCache frameworkTcImportsCache, FSharpOption1 scriptClosureOptions, FSharpList1 sourceFiles, FSharpList1 commandLineArgs, FSharpList1 projectReferences, String projectDirectory, Boolean useScriptResolutionRules, Boolean keepAssemblyContents, Boolean keepAllBackgroundResolutions)
at Microsoft.FSharp.Compiler.SourceCodeServices.BackgroundCompiler.CreateOneIncrementalBuilder(FSharpProjectOptions options, CancellationToken ct)
at
at
at Microsoft.FSharp.Control.AsyncBuilderImpl.[email protected](a a) in E:\github\visualfsharp\src\fsharpFSharp.Core\control.fs:line 825
at
at Microsoft.FSharp.Control.Trampoline.ExecuteAction(FSharpFunc`2 firstAction) in E:\github\visualfsharp\src\fsharpFSharp.Core\control.fs:line 443
at Microsoft.FSharp.Control.TrampolineHolder.Protect(FSharpFunc`2 firstAction) in E:\github\visualfsharp\src\fsharpFSharp.Core\control.fs:line 555
at
at System.Threading.QueueUserWorkItemCallback.WaitCallback_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
at System.Threading.ThreadPoolWorkQueue.Dispatch()
at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()
A new assertion (loading VisualFSharp.sln into an exp instance on current master):

I think this bug has been around for a while when editing FSHarp.Core. Multi-project support may mean it now affects all of VisualFSharp.sln. Does unloading or removing the FSharp.Core project from the solution (or even removing the ProjectReference nodes to FSharp.Core too) help?
Yes, unloading FSharp.Core project helps - everything starts working, but some red squiggles appear, like this:

RC4 + OS vsix from master:



Ok this is really annoying. Without @vasily-kirichenko helping me I would never have found this. I think it should be made top priority for VF# team.
The bug with "operation was cancelled" is fixed in https://github.com/Microsoft/visualfsharp/pull/2460
One of the remaining bugs is error to load FSharp.Core project as reference (we have to unload it to make everything work on other projects).
The error is raised here https://github.com/Microsoft/visualfsharp/blob/master/src/fsharp/CompileOps.fs#L4532. Digging into frameworkTcImports.RegisterAndImportReferencedAssemblies shows that FSharp.Core does not exists in TcImports. I think it's because it's searching for a dll and cannot find it via a project reference?
The error is raised here https://github.com/Microsoft/visualfsharp/blob/master/src/fsharp/CompileOps.fs#L4532. Digging into frameworkTcImports.RegisterAndImportReferencedAssemblies shows that FSharp.Core does not exists in TcImports. I think it's because it's searching for a dll and cannot find it via a project reference?
It could be because it's processing FSharp.Core itself, which does not have an FSharp.Core reference. This should be handled by the fact that --compiling-fslib is in the project options for that project. Could you check which assembly it is, and maybe dump a display of FSharpProjectOptions and/or TcConfig and/or TcImports, also a callstack and any other information that looks useful? thanks
@dsyme

This is dump of TcConfig.data, frameworkTcImports.CcuTable, frameworkTcImports.DllTable: https://gist.github.com/vasily-kirichenko/2f32b658ad40b48b1c28972c6990a7dd
(the dumping code is here https://github.com/Microsoft/visualfsharp/compare/master...vasily-kirichenko:fsharp.core.dump?expand=1)
Call stack:
FSharp.LanguageService.Compiler.dll!Microsoft.FSharp.Compiler.CompileOps.BuildFrameworkTcImports@4499-2.Invoke(System.Tuple<Microsoft.FSharp.Collections.FSharpList<Microsoft.FSharp.Compiler.CompileOps.ImportedBinary>, Microsoft.FSharp.Collections.FSharpList<Microsoft.FSharp.Compiler.CompileOps.AvailableImportedAssembly>> _arg7 = {System.Tuple<Microsoft.FSharp.Collections.FSharpList<Microsoft.FSharp.Compiler.CompileOps.ImportedBinary>,Microsoft.FSharp.Collections.FSharpList<Microsoft.FSharp.Compiler.CompileOps.AvailableImportedAssembly>>}) Line 4536 F#
FSharp.LanguageService.Compiler.dll!Microsoft.FSharp.Compiler.AbstractIL.Internal.Library.CancellableModule.bind@543<System.Tuple<Microsoft.FSharp.Compiler.TcGlobals.TcGlobals, Microsoft.FSharp.Compiler.CompileOps.TcImports>, System.Tuple<Microsoft.FSharp.Collections.FSharpList<Microsoft.FSharp.Compiler.CompileOps.ImportedBinary>, Microsoft.FSharp.Collections.FSharpList<Microsoft.FSharp.Compiler.CompileOps.AvailableImportedAssembly>>>.Invoke(System.Threading.CancellationToken ct = IsCancellationRequested = false) Line 552 F#
FSharp.LanguageService.Compiler.dll!Microsoft.FSharp.Compiler.AbstractIL.Internal.Library.CancellableModule.bind@543<System.Tuple<Microsoft.FSharp.Compiler.TcGlobals.TcGlobals, Microsoft.FSharp.Compiler.CompileOps.TcImports>, System.Tuple<Microsoft.FSharp.Compiler.TcGlobals.TcGlobals, Microsoft.FSharp.Compiler.CompileOps.TcImports>>.Invoke(System.Threading.CancellationToken ct = IsCancellationRequested = false) Line 547 F#
FSharp.LanguageService.Compiler.dll!Microsoft.FSharp.Compiler.AbstractIL.Internal.Library.CancellableModule.bind@543<System.Tuple<Microsoft.FSharp.Compiler.TcGlobals.TcGlobals, Microsoft.FSharp.Compiler.CompileOps.TcImports, Microsoft.FSharp.Collections.FSharpList<Microsoft.FSharp.Compiler.CompileOps.AssemblyResolution>, Microsoft.FSharp.Collections.FSharpList<Microsoft.FSharp.Compiler.CompileOps.UnresolvedAssemblyReference>>, System.Tuple<Microsoft.FSharp.Compiler.TcGlobals.TcGlobals, Microsoft.FSharp.Compiler.CompileOps.TcImports>>.Invoke(System.Threading.CancellationToken ct = IsCancellationRequested = false) Line 547 F#
FSharp.LanguageService.Compiler.dll!Microsoft.FSharp.Compiler.AbstractIL.Internal.Library.CancellableModule.bind@543<Microsoft.FSharp.Core.FSharpOption<Microsoft.FSharp.Compiler.IncrementalBuilder>, System.Tuple<Microsoft.FSharp.Compiler.TcGlobals.TcGlobals, Microsoft.FSharp.Compiler.CompileOps.TcImports, Microsoft.FSharp.Collections.FSharpList<Microsoft.FSharp.Compiler.CompileOps.AssemblyResolution>, Microsoft.FSharp.Collections.FSharpList<Microsoft.FSharp.Compiler.CompileOps.UnresolvedAssemblyReference>>>.Invoke(System.Threading.CancellationToken ct = IsCancellationRequested = false) Line 547 F#
FSharp.LanguageService.Compiler.dll!Microsoft.FSharp.Compiler.AbstractIL.Internal.Library.CancellableModule.catch@597<Microsoft.FSharp.Core.FSharpOption<Microsoft.FSharp.Compiler.IncrementalBuilder>>.Invoke(System.Threading.CancellationToken ct = IsCancellationRequested = false) Line 599 F#
FSharp.LanguageService.Compiler.dll!Microsoft.FSharp.Compiler.AbstractIL.Internal.Library.CancellableModule.bind@543<Microsoft.FSharp.Core.FSharpOption<Microsoft.FSharp.Compiler.IncrementalBuilder>, Microsoft.FSharp.Core.FSharpChoice<Microsoft.FSharp.Core.FSharpOption<Microsoft.FSharp.Compiler.IncrementalBuilder>, System.Exception>>.Invoke(System.Threading.CancellationToken ct = IsCancellationRequested = false) Line 547 F#
FSharp.LanguageService.Compiler.dll!Microsoft.FSharp.Compiler.AbstractIL.Internal.Library.CancellableModule.bind@543<System.Tuple<Microsoft.FSharp.Core.FSharpOption<Microsoft.FSharp.Compiler.IncrementalBuilder>, Microsoft.FSharp.Collections.FSharpList<Microsoft.FSharp.Compiler.FSharpErrorInfo>>, Microsoft.FSharp.Core.FSharpOption<Microsoft.FSharp.Compiler.IncrementalBuilder>>.Invoke(System.Threading.CancellationToken ct = IsCancellationRequested = false) Line 547 F#
FSharp.LanguageService.Compiler.dll!Microsoft.FSharp.Compiler.AbstractIL.Internal.Library.CancellableModule.catch@597<System.Tuple<Microsoft.FSharp.Core.FSharpOption<Microsoft.FSharp.Compiler.IncrementalBuilder>, Microsoft.FSharp.Collections.FSharpList<Microsoft.FSharp.Compiler.FSharpErrorInfo>>>.Invoke(System.Threading.CancellationToken ct = IsCancellationRequested = false) Line 599 F#
FSharp.LanguageService.Compiler.dll!Microsoft.FSharp.Compiler.AbstractIL.Internal.Library.CancellableModule.bind@543<System.Tuple<Microsoft.FSharp.Core.FSharpOption<Microsoft.FSharp.Compiler.IncrementalBuilder>, Microsoft.FSharp.Collections.FSharpList<Microsoft.FSharp.Compiler.FSharpErrorInfo>>, Microsoft.FSharp.Core.FSharpChoice<System.Tuple<Microsoft.FSharp.Core.FSharpOption<Microsoft.FSharp.Compiler.IncrementalBuilder>, Microsoft.FSharp.Collections.FSharpList<Microsoft.FSharp.Compiler.FSharpErrorInfo>>, System.Exception>>.Invoke(System.Threading.CancellationToken ct = IsCancellationRequested = false) Line 547 F#
FSharp.LanguageService.Compiler.dll!Microsoft.FSharp.Compiler.AbstractIL.Internal.Library.CancellableModule.bind@543<System.Tuple<Microsoft.FSharp.Core.FSharpOption<Microsoft.FSharp.Compiler.IncrementalBuilder>, Microsoft.FSharp.Collections.FSharpList<Microsoft.FSharp.Compiler.FSharpErrorInfo>, System.IDisposable>, System.Tuple<Microsoft.FSharp.Core.FSharpOption<Microsoft.FSharp.Compiler.IncrementalBuilder>, Microsoft.FSharp.Collections.FSharpList<Microsoft.FSharp.Compiler.FSharpErrorInfo>>>.Invoke(System.Threading.CancellationToken ct = IsCancellationRequested = false) Line 547 F#
FSharp.LanguageService.Compiler.dll!Microsoft.FSharp.Compiler.AbstractIL.Internal.Library.CancellableModule.bind@543<System.Tuple<Microsoft.FSharp.Core.FSharpOption<Microsoft.FSharp.Compiler.IncrementalBuilder>, Microsoft.FSharp.Collections.FSharpList<Microsoft.FSharp.Compiler.FSharpErrorInfo>, System.IDisposable>, System.Tuple<Microsoft.FSharp.Core.FSharpOption<Microsoft.FSharp.Compiler.IncrementalBuilder>, Microsoft.FSharp.Collections.FSharpList<Microsoft.FSharp.Compiler.FSharpErrorInfo>, System.IDisposable>>.Invoke(System.Threading.CancellationToken ct = IsCancellationRequested = false) Line 547 F#
FSharp.LanguageService.Compiler.dll!Microsoft.FSharp.Compiler.AbstractIL.Internal.Library.CancellableModule.runWithoutCancellation<System.Tuple<Microsoft.FSharp.Core.FSharpOption<Microsoft.FSharp.Compiler.IncrementalBuilder>, Microsoft.FSharp.Collections.FSharpList<Microsoft.FSharp.Compiler.FSharpErrorInfo>, System.IDisposable>>(Microsoft.FSharp.Compiler.AbstractIL.Internal.Library.Cancellable<System.Tuple<Microsoft.FSharp.Core.FSharpOption<Microsoft.FSharp.Compiler.IncrementalBuilder>, Microsoft.FSharp.Collections.FSharpList<Microsoft.FSharp.Compiler.FSharpErrorInfo>, System.IDisposable>> comp = Cancellable <fun:delay@576>) Line 584 F#
FSharp.LanguageService.Compiler.dll!<StartupCode$FSharp-LanguageService-Compiler>[email protected](Microsoft.FSharp.Compiler.AbstractIL.Internal.Library.CompilationThreadToken ctok = null) Line 2764 F#
FSharp.LanguageService.Compiler.dll!<StartupCode$FSharp-LanguageService-Compiler>[email protected](Microsoft.FSharp.Core.FSharpOption<Microsoft.FSharp.Compiler.SourceCodeServices.ReactorCommands> _arg2 = null) Line 100 F#
FSharp.Core.dll!Microsoft.FSharp.Control.AsyncBuilderImpl.cont@825<Microsoft.FSharp.Core.FSharpOption<Microsoft.FSharp.Compiler.SourceCodeServices.ReactorCommands>, Microsoft.FSharp.Core.Unit>.Invoke(Microsoft.FSharp.Core.FSharpOption<Microsoft.FSharp.Compiler.SourceCodeServices.ReactorCommands> a = null) Line 825 F#
FSharp.Core.dll!<StartupCode$FSharp-Core>[email protected](Microsoft.FSharp.Core.FSharpFunc<Microsoft.FSharp.Core.Unit, Microsoft.FSharp.Control.FakeUnitValue> action = {<StartupCode$FSharp-Core>.$Control.AwaitWaitHandle@1765-5}) Line 428 F#
FSharp.Core.dll!Microsoft.FSharp.Control.Trampoline.ExecuteAction(Microsoft.FSharp.Core.FSharpFunc<Microsoft.FSharp.Core.Unit, Microsoft.FSharp.Control.FakeUnitValue> firstAction = {<StartupCode$FSharp-Core>.$Control.AwaitWaitHandle@1765-5}) Line 443 F#
FSharp.Core.dll!Microsoft.FSharp.Control.TrampolineHolder.Protect(Microsoft.FSharp.Core.FSharpFunc<Microsoft.FSharp.Core.Unit, Microsoft.FSharp.Control.FakeUnitValue> firstAction = {<StartupCode$FSharp-Core>.$Control.AwaitWaitHandle@1765-5}) Line 555 F#
FSharp.Core.dll!<StartupCode$FSharp-Core>[email protected](object state = null, bool timedOut = true) Line 1765 F#
mscorlib.dll!System.Threading._ThreadPoolWaitOrTimerCallback.WaitOrTimerCallback_Context(object state, bool timedOut) Unknown
mscorlib.dll!System.Threading._ThreadPoolWaitOrTimerCallback.WaitOrTimerCallback_Context_t(object state) Unknown
mscorlib.dll!System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx) Unknown
mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx) Unknown
mscorlib.dll!System.Threading._ThreadPoolWaitOrTimerCallback.PerformWaitOrTimerCallback(object state, bool timedOut) Unknown
@vasily-kirichenko Tentative fix in #2098. FSharp.Core was writing a sigdata file, even when checking in-memory
Completely fixed in https://github.com/Microsoft/visualfsharp/pull/2479 馃
@vasily-kirichenko It seems to work, though when opening that file in FSharp.Editor there is an awfully long wait before information is available. This is because it checks all of FSharp.Compiler, FSharp.Core etc, but it would be good to get a full trace of what's being done to understand if work is being repeated in the project graph.
@dsyme Isn't everything cached in incremental builder?
@vasily-kirichenko Those long stacks of bind operations concern me. I always have a suspicion of long stacks in .NET causing performance problem since there is so much stack walking in GC. I may be wrong, but I suspect we should change the implementation of Cancellable.fold and Cancellable.each so that they less reliance on constructing sequences of binds and instead explicitly run the loop
See for https://github.com/Microsoft/visualfsharp/pull/2480 for the sort of thing I mean. There are other approaches to fixing this sort of problem (e.g. switch to continuations) but this should do enough I think
Isn't everything cached in incremental builder?
@vasily-kirichenko Yes it should be, and we have tests for that. But boy that pause on startup was long. It may have been because I was running the debug version of the tools though...
Most helpful comment
Ok this is really annoying. Without @vasily-kirichenko helping me I would never have found this. I think it should be made top priority for VF# team.