Skip to content

'System.StackOverflowException': tryFile -> FindCcuInfo -> ImplicitLoadIfAllowed -> RegisterAndImportReferencedAssemblies -> tryFile #378

@Thorium

Description

@Thorium

I use Windows and I have Visual Studio 2015 RC installed.
I installed Sublime text editor and F#-sublime-text-plugin and it uses FsAutoComplete. When starting Sublime and opening an empty .fs-file, FsAutoComplete crash in FSharp.Compiler.Service:

System.StackOverflowException was unhandled
Message: An unhandled exception of type 'System.StackOverflowException' occurred in mscorlib.dll

I tracked down the reason: It will open my
C:\Users\Tuomas\AppData\Local\Microsoft\VisualStudio\12.0\type-providers.txt (as requested in est.fs). This file has just one line: TRUSTED C:\git\myProject\packages\FSharp.Data\lib\net40\FSharp.Data.dll and if I delete the file, the crash still happens.

Then ReadApprovalsFile -method of est.fs is calling DoWithApprovalsFile (and particularly)

     let partiallyCanonicalizedFileName = partiallyCanonicalizeFileName(s.Substring(8))

and the DoWithApprovalsFile later line is calling TryDoWithFileStreamUnderExclusiveLockWithRetryFor500ms which has retryCount = 0 when calling TryDoWithFileStreamUnderExclusiveLock:

use file = File.Open(filename, FileMode.OpenOrCreate, FileAccess.ReadWrite)

Before that, the callstack is full of chain:
tryFile -> FindCcuInfo -> ImplicitLoadIfAllowed -> RegisterAndImportReferencedAssemblies -> tryFile

The callstack is:

mscorlib.dll!System.IO.PathHelper.GetFullPathName() Unknown
mscorlib.dll!System.IO.Path.NormalizePath(string path, bool fullCheck, int maxPathLength, bool expandShortPaths)    Unknown
mscorlib.dll!System.IO.Path.GetFullPathInternal(string path)    Unknown
mscorlib.dll!System.Security.Util.StringExpressionSet.CanonicalizePath(string path, bool needFullPath)  Unknown
mscorlib.dll!System.Security.Util.StringExpressionSet.CreateListFromExpressions(string[] str, bool needFullPath)    Unknown
mscorlib.dll!System.Security.Permissions.FileIOPermission.AddPathList(System.Security.Permissions.FileIOPermissionAccess access, System.Security.AccessControl.AccessControlActions control, string[] pathListOrig, bool checkForDuplicates, bool needFullPath, bool copyPathList)  Unknown
mscorlib.dll!System.Security.Permissions.FileIOPermission.FileIOPermission(System.Security.Permissions.FileIOPermissionAccess access, string path)  Unknown
mscorlib.dll!System.IO.FileSystemInfo.FullName.get()    Unknown >
FSharp.Compiler.Service.dll!Microsoft.FSharp.Compiler.ExtensionTyping.ApprovalIO.ReadApprovalsFile@118.Invoke(System.IO.FileStream file) Line 137   F#
FSharp.Compiler.Service.dll!Microsoft.FSharp.Compiler.ExtensionTyping.ApprovalIO.TryDoWithFileStreamUnderExclusiveLock<System.__Canon>(string filename, Microsoft.FSharp.Core.FSharpFunc<System.IO.FileStream, System.__Canon> f) Line 65   F#
FSharp.Compiler.Service.dll!Microsoft.FSharp.Compiler.ExtensionTyping.ApprovalIO.TryDoWithFileStreamUnderExclusiveLockWithRetryFor500ms<Microsoft.FSharp.Collections.FSharpList<Microsoft.FSharp.Compiler.ExtensionTyping.ApprovalIO.TypeProviderApprovalStatus>>(string filename, Microsoft.FSharp.Core.FSharpFunc<System.IO.FileStream, Microsoft.FSharp.Collections.FSharpList<Microsoft.FSharp.Compiler.ExtensionTyping.ApprovalIO.TypeProviderApprovalStatus>> f) Line 78  F#
FSharp.Compiler.Service.dll!Microsoft.FSharp.Compiler.ExtensionTyping.ApprovalIO.ReadApprovalsFile(Microsoft.FSharp.Core.FSharpOption<System.IO.FileStream> fileStreamOpt) Line 118 F#
FSharp.Compiler.Service.dll!Microsoft.FSharp.Compiler.Build.TcImports.RegisterAndImportReferencedAssemblies(Microsoft.FSharp.Core.FSharpOption<Microsoft.FSharp.Core.FSharpFunc<string, Microsoft.FSharp.Core.Unit>> displayPSTypeProviderSecurityDialogBlockingUI, Microsoft.FSharp.Collections.FSharpList<Microsoft.FSharp.Compiler.Build.AssemblyResolution> nms) Line 4382  F#
FSharp.Compiler.Service.dll!Microsoft.FSharp.Compiler.Build.tryFile@4408(Microsoft.FSharp.Compiler.Build.TcImports tcImports, Microsoft.FSharp.Compiler.Range.range m, string speculativeFileName) Line 4414    F#
FSharp.Compiler.Service.dll!Microsoft.FSharp.Compiler.Build.TcImports.ImplicitLoadIfAllowed(Microsoft.FSharp.Compiler.Range.range m, string assemblyName, bool lookupOnly) Line 4407    F#
FSharp.Compiler.Service.dll!Microsoft.FSharp.Compiler.Build.TcImports.FindCcuInfo(Microsoft.FSharp.Compiler.Range.range m, string assemblyName, bool lookupOnly) Line 3794  F#
FSharp.Compiler.Service.dll!Microsoft.FSharp.Compiler.Build.RegisterAndPrepareToImportReferencedDll@4351.Invoke(Microsoft.FSharp.Core.Unit unitVar0) Line 4351  F#
FSharp.Compiler.Service.dll!Microsoft.FSharp.Compiler.Build.TcImports.RegisterAndImportReferencedAssemblies(Microsoft.FSharp.Core.FSharpOption<Microsoft.FSharp.Core.FSharpFunc<string, Microsoft.FSharp.Core.Unit>> displayPSTypeProviderSecurityDialogBlockingUI, Microsoft.FSharp.Collections.FSharpList<Microsoft.FSharp.Compiler.Build.AssemblyResolution> nms) Line 4386  F#
FSharp.Compiler.Service.dll!Microsoft.FSharp.Compiler.Build.tryFile@4408(Microsoft.FSharp.Compiler.Build.TcImports tcImports, Microsoft.FSharp.Compiler.Range.range m, string speculativeFileName) Line 4414    F#
FSharp.Compiler.Service.dll!Microsoft.FSharp.Compiler.Build.TcImports.ImplicitLoadIfAllowed(Microsoft.FSharp.Compiler.Range.range m, string assemblyName, bool lookupOnly) Line 4407    F#
FSharp.Compiler.Service.dll!Microsoft.FSharp.Compiler.Build.TcImports.FindCcuInfo(Microsoft.FSharp.Compiler.Range.range m, string assemblyName, bool lookupOnly) Line 3794  F#
FSharp.Compiler.Service.dll!Microsoft.FSharp.Compiler.Build.RegisterAndPrepareToImportReferencedDll@4351.Invoke(Microsoft.FSharp.Core.Unit unitVar0) Line 4351  F#
FSharp.Compiler.Service.dll!Microsoft.FSharp.Compiler.Build.TcImports.RegisterAndImportReferencedAssemblies(Microsoft.FSharp.Core.FSharpOption<Microsoft.FSharp.Core.FSharpFunc<string, Microsoft.FSharp.Core.Unit>> displayPSTypeProviderSecurityDialogBlockingUI, Microsoft.FSharp.Collections.FSharpList<Microsoft.FSharp.Compiler.Build.AssemblyResolution> nms) Line 4386  F#
FSharp.Compiler.Service.dll!Microsoft.FSharp.Compiler.Build.tryFile@4408(Microsoft.FSharp.Compiler.Build.TcImports tcImports, Microsoft.FSharp.Compiler.Range.range m, string speculativeFileName) Line 4414    F#
FSharp.Compiler.Service.dll!Microsoft.FSharp.Compiler.Build.TcImports.ImplicitLoadIfAllowed(Microsoft.FSharp.Compiler.Range.range m, string assemblyName, bool lookupOnly) Line 4407    F#
FSharp.Compiler.Service.dll!Microsoft.FSharp.Compiler.Build.TcImports.FindCcuInfo(Microsoft.FSharp.Compiler.Range.range m, string assemblyName, bool lookupOnly) Line 3794  F#
FSharp.Compiler.Service.dll!Microsoft.FSharp.Compiler.Build.RegisterAndPrepareToImportReferencedDll@4351.Invoke(Microsoft.FSharp.Core.Unit unitVar0) Line 4351  F#
...

fcs-command tells the version: Microsoft (R) F# Compiler version 14.0.22810.0.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions