madskristensen / WebEssentials2012

http://vswebessentials.com
Other
95 stars 46 forks source link

Visual Studio crashes after TypeScript compile #61

Open albinsunnanbo opened 10 years ago

albinsunnanbo commented 10 years ago

After / during TypeScript compilation Visual Studio crashes. It happens most of the time, but not always. It might be only when I have an open TypeScript file in Visual Studio. I found this in my event log

Application: devenv.exe Framework Version: v4.0.30319 Description: The process was terminated due to an unhandled exception. Exception Info: System.IO.IOException Stack: at System.IO.__Error.WinIOError(Int32, System.String) at System.IO.FileStream.Init(System.String, System.IO.FileMode, System.IO.FileAccess, Int32, Boolean, System.IO.FileShare, Int32, System.IO.FileOptions, SECURITY_ATTRIBUTES, System.String, Boolean, Boolean, Boolean) at System.IO.FileStream..ctor(System.String, System.IO.FileMode, System.IO.FileAccess, System.IO.FileShare, Int32, System.IO.FileOptions, System.String, Boolean, Boolean, Boolean) at System.IO.StreamReader..ctor(System.String, System.Text.Encoding, Boolean, Int32, Boolean) at System.IO.File.InternalReadAllText(System.String, System.Text.Encoding, Boolean) at System.IO.File.ReadAllText(System.String) at MadsKristensen.EditorExtensions.TypeScriptMargin+<>cDisplayClass12.b10() at System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate, System.Object, Int32) at MS.Internal.Threading.ExceptionFilterHelper.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 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 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 MS.Internal.Threading.ExceptionFilterHelper.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)

especially the line

MadsKristensen.EditorExtensions.TypeScriptMargin+<>cDisplayClass12.b10()

makes me suspect WebEssentials.

The Visual Studio about box tells the following info

Microsoft Visual Studio Professional 2012 Version 11.0.61030.00 Update 4 Microsoft .NET Framework Version 4.5.51641

Installed Version: Professional

LightSwitch for Visual Studio 2012 04938-004-0033001-02017 Microsoft LightSwitch for Visual Studio 2012

Office Developer Tools 04938-004-0033001-02017 Microsoft Office Developer Tools

Team Explorer for Visual Studio 2012 04938-004-0033001-02017 Microsoft Team Explorer for Visual Studio 2012

Visual Basic 2012 04938-004-0033001-02017 Microsoft Visual Basic 2012

Visual C# 2012 04938-004-0033001-02017 Microsoft Visual C# 2012

Visual C++ 2012 04938-004-0033001-02017 Microsoft Visual C++ 2012

Visual F# 2012 04938-004-0033001-02017 Microsoft Visual F# 2012

Visual Studio 2012 Code Analysis Spell Checker
04938-004-0033001-02017 Microsoft® Visual Studio® 2012 Code Analysis Spell Checker

Portions of International CorrectSpell™ spelling correction system © 1993 by Lernout & Hauspie Speech Products N.V. All rights reserved.

The American Heritage® Dictionary of the English Language, Third Edition Copyright © 1992 Houghton Mifflin Company. Electronic version licensed from Lernout & Hauspie Speech Products N.V. All rights reserved.

Visual Studio 2012 SharePoint Developer Tools
04938-004-0033001-02017 Microsoft Visual Studio 2012 SharePoint Developer Tools

ASP.NET and Web Tools 2012.3.41009 Microsoft Web Developer Tools contains the following components: Support for creating and opening ASP.NET web projects Browser Link: A communication channel between Visual Studio and browsers Editor extensions for HTML, CSS, and JavaScript Page Inspector: Inspection tool for ASP.NET web projects Scaffolding: A framework for building and running code generators Server Explorer extensions for Windows Azure Web Sites Web publishing: Extensions for publishing ASP.NET web projects to hosting providers, on-premises servers, or Windows Azure

IdentityAndAccessVSPackage 1.0 Identity and Access VS Package

jslint.VS2012 1.0 Adds JSLlint support into Visual Studio

Microsoft Enterprise Library Configuration Console 1.0 Launcher for the Microsoft Enterprise Library Configuration Console.

Microsoft Team Foundation Server 2012 Power Tools 3.0 Power Tools that extend the Team Foundation Server integration with Visual Studio.

Microsoft Visual Studio Process Editor 1.0 Process Editor for Microsoft Visual Studio Team Foundation Server

Node.js Tools 1.0.11119.03 Adds support for developing and debugging Node.js apps in Visual Studio

Node.js Tools - Profiling 1.0.11119.03 Profiling support for Node.js projects.

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

PreEmptive Analytics Visualizer 1.0 Microsoft Visual Studio extension to visualize aggregated summaries from the PreEmptive Analytics product.

SQL Server Data Tools 11.1.40318.0 Microsoft SQL Server Data Tools

Visual Studio 11 Editor Extension 1.0 Information about my package

I'm running Windows 8.1 64 bit. I have installed "TypeScript Tools for Visual Studio 2012" v 1.0 from april 1.

Based in the vague information in this bug report, can you confirm that this is a Web Essentials Issue? Can I provide more relevant information to help research the issue?

albinsunnanbo commented 10 years ago

I download the source and tried to debug.

I get the following stack trace

System.IO.IOException was unhandled HResult=-2147024864
Message=The process cannot access the file 'C:path\calendar.js' because it is being used by another process. Source=mscorlib
StackTrace: at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost) at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost) at System.IO.StreamReader..ctor(String path, Encoding encoding, Boolean detectEncodingFromByteOrderMarks, Int32 bufferSize, Boolean checkHost) at System.IO.File.InternalReadAllText(String path, Encoding encoding, Boolean checkHost) at System.IO.File.ReadAllText(String path) at MadsKristensen.EditorExtensions.TypeScriptMargin.<>cDisplayClass12.b10() 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.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.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.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs) at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam) InnerException:

The anonymous method c__DisplayClass12.<UpdateMargin>b__10 is the line TypeScriptMargin.cs:58 (OnCompilationDone(File.ReadAllText(jsFile), jsFile); in the method UpdateMargin).

I run procmon and it seems like there is some "FILE LOCKED WITH WRITERS" by C:\Program Files\Windows Defender\MsMpEng.exe (Antimalware Service Executable) going right before the "SHARING VIOLATION" in devenv.exe

20:42:53,2621610 tsc.exe 9292 QueryDirectory C:path\calendar.js.map SUCCESS Filter: calendar.js.map, 1: calendar.js.map 20:42:53,2631202 tsc.exe 9292 CreateFile C:path\calendar.js.map SUCCESS Desired Access: Generic Write, Read Attributes, Disposition: OverwriteIf, Options: Sequential Access, Synchronous IO Non-Alert, Non-Directory File, Disallow Exclusive, Attributes: N, ShareMode: None, AllocationSize: 0, OpenResult: Overwritten 20:42:53,2636316 tsc.exe 9292 WriteFile C:path\calendar.js.map SUCCESS Offset: 0, Length: 2 048, Priority: Normal 20:42:53,2637485 tsc.exe 9292 WriteFile C:path\calendar.js.map SUCCESS Offset: 2 048, Length: 950 20:42:53,2638008 tsc.exe 9292 CloseFile C:path\calendar.js.map SUCCESS 20:42:53,2640623 MsMpEng.exe 1808 CreateFileMapping C:path\calendar.js.map FILE LOCKED WITH WRITERS SyncType: SyncTypeCreateSection, PageProtection: 20:42:53,2640878 MsMpEng.exe 1808 QueryStandardInformationFile C:path\calendar.js.map SUCCESS AllocationSize: 4 096, EndOfFile: 2 998, NumberOfLinks: 1, DeletePending: False, Directory: False 20:42:53,2668456 tsc.exe 9292 QueryDirectory C:path\calendar.js SUCCESS Filter: calendar.js, 1: calendar.js 20:42:53,2676708 tsc.exe 9292 CreateFile C:path\calendar.js SUCCESS Desired Access: Generic Write, Read Attributes, Disposition: OverwriteIf, Options: Sequential Access, Synchronous IO Non-Alert, Non-Directory File, Disallow Exclusive, Attributes: N, ShareMode: None, AllocationSize: 0, OpenResult: Overwritten 20:42:53,2681040 devenv.exe 10200 CreateFile C:path\calendar.js SUCCESS Desired Access: Read Attributes, Disposition: Open, Options: Open Reparse Point, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a, OpenResult: Opened 20:42:53,2681446 devenv.exe 10200 QueryNetworkOpenInformationFile C:path\calendar.js SUCCESS CreationTime: 2013-09-15 08:53:01, LastAccessTime: 2014-04-03 20:42:40, LastWriteTime: 2014-04-03 20:42:53, ChangeTime: 2014-04-03 20:42:53, AllocationSize: 1601-01-01 02:00:00, EndOfFile: 1601-01-01 02:00:00, FileAttributes: A 20:42:53,2681612 devenv.exe 10200 CloseFile C:path\calendar.js SUCCESS 20:42:53,2684007 devenv.exe 10200 CreateFile C:path\calendar.js SHARING VIOLATION Desired Access: Generic Read, Disposition: Open, Options: Sequential Access, Synchronous IO Non-Alert, Non-Directory File, Open No Recall, Attributes: n/a, ShareMode: Read, AllocationSize: n/a 20:42:53,2698410 tsc.exe 9292 WriteFile C:path\calendar.js SUCCESS Offset: 0, Length: 2 048, Priority: Normal 20:42:53,2699764 tsc.exe 9292 WriteFile C:path\calendar.js SUCCESS Offset: 2 048, Length: 1 094 20:42:53,2700018 tsc.exe 9292 CloseFile C:path\calendar.js SUCCESS 20:42:53,2703548 MsMpEng.exe 1808 CreateFileMapping C:path\calendar.js FILE LOCKED WITH WRITERS SyncType: SyncTypeCreateSection, PageProtection: 20:42:53,2704443 MsMpEng.exe 1808 QueryStandardInformationFile C:path\calendar.js SUCCESS AllocationSize: 4 096, EndOfFile: 3 142, NumberOfLinks: 1, DeletePending: False, Directory: False 20:42:53,3202337 devenv.exe 10200 CreateFile C:path\calendar.js SUCCESS Desired Access: Read Attributes, Disposition: Open, Options: Open Reparse Point, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a, OpenResult: Opened 20:42:53,3202738 devenv.exe 10200 QueryNetworkOpenInformationFile C:path\calendar.js SUCCESS CreationTime: 2013-09-15 08:53:01, LastAccessTime: 2014-04-03 20:42:40, LastWriteTime: 2014-04-03 20:42:53, ChangeTime: 2014-04-03 20:42:53, AllocationSize: 1601-01-01 02:00:00, EndOfFile: 1601-01-01 02:00:00, FileAttributes: A 20:42:53,3202929 devenv.exe 10200 CloseFile C:path\calendar.js SUCCESS

(real path replace with c:path in stack trace and procmon dump.)

albinsunnanbo commented 10 years ago

The chance to reproduce seems to increase if I revert all .js files in my solution and keep lots of .ts files open in Visual Studio.

albinsunnanbo commented 10 years ago

I implemented a small hack as a workaround in https://github.com/albinsunnanbo/WebEssentials2012/tree/issue61 I wouldn't count it as production quality fix. It is more like a workaround that reduces the risk of hitting the bug.

npelletm commented 10 years ago

I experiment the same issue with typescript 1.0. I'm running on windows 7 x64.