TODO crashes Visual Studio

I've got an interesting one...

I have Visual Studio 2010 Professional, with ReSharper 5.0.1659.36.  I just installed ReSharper, and now, any time I open a code file with "// TODO" somewhere in it, or if I type a TODO comment, Visual Studio immediately crashes (within a second or two).  It's very recreateable and predictable.  Prior to installing ReSharper, this didn't occur.  I also installed StyleCop and integrated StyleCop into ReSharper at the same time as installing ReSharper, so it's possible that this is related.

I also have VS 2003, 2005, and 2008 on this machine, and have used ReSharper 3 and 4 with no problems (other than normal ones), so it's possible that some settings have migrated into the new version somehow, but I don't know if those are related.

The problem occurs regardless of whether a solution is open, or just opening a plain .cs file from scratch.

The error I get is a FileFormatException: I opened a new VS instance to debug the problem, and below is my exception details.  I don't see any JetBrains in there, but I really have no idea how R# and VS integrate, to be able to figure out much else.

Has anyone else experience anything similar, and do you have any ideas on what I can check to prevent this problem?

Thanks for your help.

Joe


Exception details:

System.IO.FileFormatException was unhandled
  Message=Input file or data stream does not conform to the expected file format specification.
  Source=PresentationCore
  StackTrace:
       at MS.Internal.TextFormatting.TextMetrics.FullTextLine.FormatLine(FullTextState fullText, Int32 cpFirst, Int32 lineLength, Int32 formatWidth, Int32 finiteFormatWidth, Int32 paragraphWidth, LineFlags lineFlags, FormattedTextSymbols collapsingSymbol)
       at MS.Internal.TextFormatting.TextFormatterImp.FormatLineInternal(TextSource textSource, Int32 firstCharIndex, Int32 lineLength, Double paragraphWidth, TextParagraphProperties paragraphProperties, TextLineBreak previousLineBreak, TextRunCache textRunCache)
       at MS.Internal.TextFormatting.TextFormatterImp.FormatLine(TextSource textSource, Int32 firstCharIndex, Double paragraphWidth, TextParagraphProperties paragraphProperties, TextLineBreak previousLineBreak)
       at Microsoft.VisualStudio.Text.Formatting.Implementation.NormalizedSpanManager.FormatLine(Double indentation, Double maxTextWidth, TextParagraphProperties paragraphProperties)
       at Microsoft.VisualStudio.Text.Formatting.Implementation.FormattedLineSource.Format(ITextAndAdornmentCollection elements, ITextSnapshotLine line)
       at Microsoft.VisualStudio.Text.Formatting.Implementation.FormattedLineSource.FormatLineInVisualBuffer(ITextSnapshotLine visualLine)
       at Microsoft.VisualStudio.Text.Editor.Implementation.WpfTextView.FormatSnapshotLine(ITextSnapshotLine visualLine)
       at Microsoft.VisualStudio.Text.Editor.Implementation.WpfTextView.DoLayoutDown(ITextSnapshotLine visualLine, Double referenceLine, Double effectiveViewportHeight, Double& distanceBelowReferenceLine)
       at Microsoft.VisualStudio.Text.Editor.Implementation.WpfTextView.DoCompleteLayout(SnapshotPoint anchorPosition, Double verticalDistance, ViewRelativePosition relativeTo, Double effectiveViewportHeight, Double& referenceLine, Double& distanceAboveReferenceLine, Double& distanceBelowReferenceLine)
       at Microsoft.VisualStudio.Text.Editor.Implementation.WpfTextView.InnerPerformLayout(SnapshotPoint anchorPosition, Double verticalDistance, ViewRelativePosition relativeTo, Double effectiveViewportWidth, Double effectiveViewportHeight)
       at Microsoft.VisualStudio.Text.Editor.Implementation.WpfTextView.PerformLayout(ITextSnapshot newSnapshot, ITextSnapshot newVisualSnapshot, SnapshotPoint anchorPosition, Double verticalDistance, ViewRelativePosition relativeTo, Double effectiveViewportWidth, Double effectiveViewportHeight)
       at Microsoft.VisualStudio.Text.Editor.Implementation.WpfTextView.PerformLayout(ITextSnapshot newSnapshot, ITextSnapshot newVisualSnapshot)
       at Microsoft.VisualStudio.Text.Editor.Implementation.WpfTextView.<QueueLayout>b__14(Object )
       at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
       at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
       at System.Windows.Threading.DispatcherOperation.InvokeImpl()
       at System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(Object state)
       at System.Threading.ExecutionContext.runTryCode(Object userData)
       at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
       at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Windows.Threading.DispatcherOperation.Invoke()
       at System.Windows.Threading.Dispatcher.ProcessQueue()
       at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
       at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
       at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
       at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
       at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
       at System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
       at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
  InnerException: System.IO.FileFormatException
       Message=Input file or data stream does not conform to the expected file format specification.
       Source=PresentationCore
       StackTrace:
            at MS.Internal.Text.TextInterface.Native.Util.ConvertHresultToException(Int32 hr)
            at MS.Internal.Text.TextInterface.Font.CreateFontFace()
            at MS.Internal.Text.TextInterface.Font.AddFontFaceToCache()
            at MS.Internal.Text.TextInterface.Font.GetFontFace()
            at System.Windows.Media.GlyphTypeface..ctor(Font font)
            at MS.Internal.FontFace.PhysicalFontFamily.GetGlyphTypeface(FontStyle style, FontWeight weight, FontStretch stretch)
            at MS.Internal.FontFace.PhysicalFontFamily.MS.Internal.FontFace.IFontFamily.GetTypefaceMetrics(FontStyle style, FontWeight weight, FontStretch stretch)
            at System.Windows.Media.Typeface.ConstructCachedTypeface()
            at System.Windows.Media.Typeface.get_CachedTypeface()
            at System.Windows.Media.Typeface.get_Symbol()
            at MS.Internal.TextFormatting.TextStore.FetchTextRun(Int32 cpFetch)
            at MS.Internal.TextFormatting.TextStore.FetchLSRun(Int32 lscpFetch, TextFormattingMode textFormattingMode, Boolean isSideways, Plsrun& plsrun, Int32& lsrunOffset, Int32& lsrunLength)
            at MS.Internal.TextFormatting.LineServicesCallbacks.FetchRunRedefined(IntPtr pols, Int32 lscpFetch, Int32 fIsStyle, IntPtr pstyle, Char* pwchTextBuffer, Int32 cchTextBuffer, Int32& fIsBufferUsed, Char*& pwchText, Int32& cchText, Int32& fIsHidden, LsChp& lschp, IntPtr& lsplsrun)
       InnerException:

6 comments
Comment actions Permalink

Hello Joe
     Does this happen if you suspend ReSharper (under Tools > Options > ReSharper > General) before opening a .cs file with TODO comments? Does this occur if the .cs file contains 'BUG' or 'NOTE' comments? Thank you!

Andrey Serebryansky

Support Engineer

JetBrains, Inc

http://www.jetbrains.com

"Develop with pleasure!"
0
Comment actions Permalink

When I suspend ReSharper, the problem does not occur.  I can open codefiles with TODO comments and type them in myself, with no problems.  When I turn ReSharper back on, I can crash Visual Studio right away the same way, by either opening a codefile or typing // TODO manually.

This problem does not occur with NOTE or BUG comments.

I should mention that it's not just "// TODO", but rather the word TODO (in upper or lower case) at any point within any comment, including block comments.  For example, if I start typing "test test todo" inside of an existing /* */ block, it will crash as soon as I finish typing todo.

Thanks for looking into this.

0
Comment actions Permalink

Hello,

ReSharper has the "TODO Explorer" feature which will list all of the TODO-containing
comments across the solution, as well as highlight them in the code file.

What happens here looks like the WPF engine failing to process the formatting
at this specfic location. I think it's also worth reporting to Microsoft.

Seems like you have some of the system files corrupted -- either TrueType/OpenType
fonts, or WPF resources. Repairing fonts or .NET framework could possibly
help.

As a workaround, you could try changing the editor font (which one are you
using?), or the ReSharper fonts'n'colors entry for highlighting the TODO
items to not use the bold typeface.


Serge Baltic
JetBrains, Inc — http://www.jetbrains.com
“Develop with pleasure!”


0
Comment actions Permalink

Awesome, thanks for checking that out.  I'm out of the office today, but I'm back in tomorrow, so I'll try it tomorrow morning and let you know if that worked.

0
Comment actions Permalink

The font was definitely the problem.  I was using DejaVu Sans Mono, and I tried a couple things, as you suggested.  I turned off "Bold" for Todo comments, and the crash no longer occurred.  I turned it back on, and switched to Consolas, and the crash no longer occurred.  I then set it back to DejaVu Sans Mono with bold, and the crash
occurred again (just to make sure that it didn't somehow fix itself).  I then tried the "bold" option on DejaVu Sans Mono with just plain text (the default text editor settings), and got the crash opening a plain text file.

So the combination of DejaVu Sans Mono with the bold is definitely what was causing it.  I'll look into this more, to see if it's an isolated incident with my machine or if I can recreate it elsewhere, and pass it on to Microsoft if it's recreateable on other machines.

Thank you very much for your help.

0
Comment actions Permalink

I ran into the same problem. I upgraded to the latest version of Dejavu, and that fixed it.

0

Please sign in to leave a comment.