dotnet / fsharp

The F# compiler, F# core library, F# language service, and F# tooling integration for Visual Studio
https://dotnet.microsoft.com/languages/fsharp
MIT License
3.85k stars 779 forks source link

Typing `with get()` causes unhandled FileFormatException #6638

Closed voronoipotato closed 5 years ago

voronoipotato commented 5 years ago

Please provide a succinct description of the issue.

Repro steps

Open VS2019

https://gist.github.com/voronoipotato/f7241ac9705488fb56e7f049dfe08114

To reproduce create a new F# console application

// Learn more about F# at http://fsharp.org

type X() =
    member this.Y with g//crashes here

open System

[<EntryPoint>]
let main argv =
    printfn "Hello World from F#!"
    0 // return an integer exit code

Expected behavior

no crash

Actual behavior

- <Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
- <System>
  <Provider Name=".NET Runtime" /> 
  <EventID Qualifiers="0">1026</EventID> 
  <Level>2</Level> 
  <Task>0</Task> 
  <Keywords>0x80000000000000</Keywords> 
  <TimeCreated SystemTime="2019-04-25T20:51:48.268585600Z" /> 
  <EventRecordID>496557</EventRecordID> 
  <Channel>Application</Channel> 
  <Computer>AWB-M720-10.nchfa.com</Computer> 
  <Security /> 
  </System>
- <EventData>
  <Data>Application: devenv.exe Framework Version: v4.0.30319 Description: The process was terminated due to an unhandled exception. Exception Info: System.IO.FileFormatException at MS.Internal.Text.TextInterface.Native.Util.ConvertHresultToException(Int32) at MS.Internal.Text.TextInterface.TextAnalyzer.GetGlyphPlacements(UInt16*, UInt16*, UInt16*, UInt32, UInt16*, UInt32*, UInt32, MS.Internal.Text.TextInterface.Font, Double, Double, Boolean, Boolean, System.Globalization.CultureInfo, MS.Internal.Text.TextInterface.DWriteFontFeature[][], UInt32[], System.Windows.Media.TextFormattingMode, MS.Internal.Text.TextInterface.ItemProps, Single, Int32*, MS.Internal.Text.TextInterface.GlyphOffset[] ByRef) at MS.Internal.TextFormatting.LineServicesCallbacks.GetGlyphPositions(IntPtr, IntPtr*, Int32*, Int32, MS.Internal.TextFormatting.LsDevice, Char*, UInt16*, UInt16*, Int32, UInt16*, UInt32*, Int32, MS.Internal.TextFormatting.LsTFlow, Int32*, MS.Internal.Text.TextInterface.GlyphOffset*) Exception Info: System.IO.FileFormatException at MS.Internal.TextFormatting.TextMetrics+FullTextLine.FormatLine(MS.Internal.TextFormatting.FullTextState, Int32, Int32, Int32, Int32, Int32, MS.Internal.TextFormatting.LineFlags, MS.Internal.TextFormatting.FormattedTextSymbols) at MS.Internal.TextFormatting.TextMetrics+FullTextLine..ctor(MS.Internal.TextFormatting.FormatSettings, Int32, Int32, Int32, MS.Internal.TextFormatting.LineFlags) at MS.Internal.TextFormatting.TextFormatterImp.FormatLineInternal(System.Windows.Media.TextFormatting.TextSource, Int32, Int32, Double, System.Windows.Media.TextFormatting.TextParagraphProperties, System.Windows.Media.TextFormatting.TextLineBreak, System.Windows.Media.TextFormatting.TextRunCache) at MS.Internal.TextFormatting.TextFormatterImp.FormatLine(System.Windows.Media.TextFormatting.TextSource, Int32, Double, System.Windows.Media.TextFormatting.TextParagraphProperties, System.Windows.Media.TextFormatting.TextLineBreak, System.Windows.Media.TextFormatting.TextRunCache) at MS.Internal.Text.Line.Format(Int32, Double, System.Windows.Media.TextFormatting.TextParagraphProperties, System.Windows.Media.TextFormatting.TextLineBreak, System.Windows.Media.TextFormatting.TextRunCache, Boolean) at System.Windows.Controls.TextBlock.MeasureOverride(System.Windows.Size) at System.Windows.FrameworkElement.MeasureCore(System.Windows.Size) at System.Windows.UIElement.Measure(System.Windows.Size) at System.Windows.ContextLayoutManager.UpdateLayout() at System.Windows.UIElement.UpdateLayout() at System.Windows.Controls.VirtualizingStackPanel+<>c__DisplayClass94_0.<InitializeViewport>b__0() at System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate, System.Object, Int32) at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(System.Object, System.Delegate, System.Object, Int32, System.Delegate) at System.Windows.Threading.DispatcherOperation.InvokeImpl() at System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(System.Object) at MS.Internal.CulturePreservingExecutionContext.CallbackWrapper(System.Object) at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean) at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean) at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object) at MS.Internal.CulturePreservingExecutionContext.Run(MS.Internal.CulturePreservingExecutionContext, System.Threading.ContextCallback, System.Object) at System.Windows.Threading.DispatcherOperation.Invoke() at System.Windows.Threading.Dispatcher.ProcessQueue() at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr, Int32, IntPtr, IntPtr, Boolean ByRef) at MS.Win32.HwndWrapper.WndProc(IntPtr, Int32, IntPtr, IntPtr, Boolean ByRef) at MS.Win32.HwndSubclass.DispatcherCallbackOperation(System.Object) at System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate, System.Object, Int32) at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(System.Object, System.Delegate, System.Object, Int32, System.Delegate) at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(System.Windows.Threading.DispatcherPriority, System.TimeSpan, System.Delegate, System.Object, Int32) at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr, Int32, IntPtr, IntPtr)</Data> 
  </EventData>
  </Event>

Installed products

Microsoft Visual Studio Enterprise 2019
Version 16.0.2
VisualStudio.16.Release/16.0.2+28803.202
Microsoft .NET Framework
Version 4.7.03056

Installed Version: Enterprise

ADL Tools Service Provider   1.0
This package contains services used by Data Lake tools

Application Insights Tools for Visual Studio Package   9.0.20307.1
Application Insights Tools for Visual Studio

ASP.NET and Web Tools 2019   16.0.12311.10635
ASP.NET and Web Tools 2019

ASP.NET Web Frameworks and Tools 2019   16.0.12311.10635
For additional information, visit https://www.asp.net/

Azure App Service Tools v3.0.0   16.0.12311.10635
Azure App Service Tools v3.0.0

Azure Data Lake Node   1.0
This package contains the Data Lake integration nodes for Server Explorer.

Azure Data Lake Tools for Visual Studio   2.3.7000.2
Microsoft Azure Data Lake Tools for Visual Studio

Azure Functions and Web Jobs Tools   16.0.12311.10635
Azure Functions and Web Jobs Tools

Azure Stream Analytics Tools for Visual Studio   2.3.7000.2
Microsoft Azure Stream Analytics Tools for Visual Studio

C# Tools   3.0.0-beta4-19170-01+1deafee3682da88bf07d1c18521a99f47446cee8
C# components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Common Azure Tools   1.10
Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.

Microsoft Azure HDInsight Azure Node   2.3.7000.2
HDInsight Node under Azure Node

Microsoft Azure Hive Query Language Service   2.3.7000.2
Language service for Hive query

Microsoft Azure Stream Analytics Language Service   2.3.7000.2
Language service for Azure Stream Analytics

Microsoft Azure Stream Analytics Node   1.0
Azure Stream Analytics Node under Azure Node

Microsoft Azure Tools   2.9
Microsoft Azure Tools for Microsoft Visual Studio 0x10 - v2.9.0.0

Microsoft Continuous Delivery Tools for Visual Studio   0.4
Simplifying the configuration of Azure DevOps pipelines from within the Visual Studio IDE.

Microsoft JVM Debugger   1.0
Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines

Microsoft Library Manager   1.0
Install client-side libraries easily to any web project

Microsoft MI-Based Debugger   1.0
Provides support for connecting Visual Studio to MI compatible debuggers

Microsoft Visual Studio Tools for Containers   1.1
Develop, run, validate your ASP.NET Core applications in the target environment. F5 your application directly into a container with debugging, or CTRL + F5 to edit & refresh your app without having to rebuild the container.

Node.js Tools   1.5.10301.2 Commit Hash:9c34eb81d73db6babeb71674feb1cb437dba9f2f
Adds support for developing and debugging Node.js apps in Visual Studio

NuGet Package Manager   5.0.0
NuGet Package Manager in Visual Studio. For more information about NuGet, visit http://docs.nuget.org/.

ProjectServicesPackage Extension   1.0
ProjectServicesPackage Visual Studio Extension Detailed Info

ResourcePackage Extension   1.0
ResourcePackage Visual Studio Extension Detailed Info

ResourcePackage Extension   1.0
ResourcePackage Visual Studio Extension Detailed Info

Snapshot Debugging Extension   1.0
Snapshot Debugging Visual Studio Extension Detailed Info

SQL Server Data Tools   16.0.61903.25110
Microsoft SQL Server Data Tools

Syntax Visualizer   1.0
An extension for visualizing Roslyn SyntaxTrees.

ToolWindowHostedEditor   1.0
Hosting json editor into a tool window

TypeScript Tools   16.0.10306.2001
TypeScript Tools for Microsoft Visual Studio

Visual Basic Tools   3.0.0-beta4-19170-01+1deafee3682da88bf07d1c18521a99f47446cee8
Visual Basic components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Visual F# Tools 10.4 for F# 4.6   16.0.0.0.  Commit Hash: 809f41207b74a1356208f11b8fa3a15233734050.
Microsoft Visual F# Tools 10.4 for F# 4.6

Visual Studio Code Debug Adapter Host Package   1.0
Interop layer for hosting Visual Studio Code debug adapters in Visual Studio

Visual Studio Tools for Containers   1.0
Visual Studio Tools for Containers

Known workarounds

open a different editor and type get

Related information

Provide any related information Windows 10 Version 10.0.17134 Build 17134 , VS 2019 16.0.2,

Severity: 🤕

cartermp commented 5 years ago

Is this with the linked code fix built into a hive, or is this just with File | New project and no custom F# extension?

voronoipotato commented 5 years ago

File new project and no custom extension

cartermp commented 5 years ago

Thanks. I can't reproduce this by typing it out in VS 2019 in either a .NET SDK or legacy style console project, nor with various ways attempted to type it. I don't have the same set of extensions nor setup.

Looking at the stack trace, nothing there is from the F# tools or the Roslyn host, so without an ability to reproduce it here I think GitHub won't be the appropriate avenue. I'd recommend first doing a repair to see if something was installed with an issue. If that doesn't resolve it, using the Report a Problem tool will collect system diagnostics (including logs) that can help in tracking this down.

voronoipotato commented 5 years ago

ok thanks

marklam commented 5 years ago

Just a guess, but are you using a downloaded font in the editor?

voronoipotato commented 5 years ago

Yes pragmatapro

marklam commented 5 years ago

That's probably key for the repro - it looks (from the stack trace) like it's caused by GetGlyphPlacements returning an error HRESULT so perhaps there's a problem with that font, or its installation, or a bug in WPF / DirectWrite.

Hope that helps.

voronoipotato commented 5 years ago

If it helps to say I've had no problems with the font in visual studio in C#, I've used the font unchanged for at least 7 years now. I use it daily with C#, VB, and in VSCode. Given what you've said in my perception it's likely that either F# or the visual F# tooling is triggering a edge-case in WPF/Directwrite.

voronoipotato commented 5 years ago

Okay this just happened in C# in vs 2019. I was typing a return statement and it just crashed. I think it may be my font that is triggering it. Is there a way we can escalate this to the VS 2019 crew, or at least disable my font on the autocomplete suggestions? It seems to only happen when I get a suggestion window opening.

cartermp commented 5 years ago

@voronoipotato I recommend using the Report a Problem tool with the info you've supplied here. Crash data is sent automatically to Microsoft (enabled by default), so there will be crash info available for people to look at on our end.

cartermp commented 5 years ago

Also I believe this setting should do it for you image