Open albinsunnanbo opened 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.b 10() 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.)
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.
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.
I experiment the same issue with typescript 1.0. I'm running on windows 7 x64.
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
especially the line
makes me suspect WebEssentials.
The Visual Studio about box tells the following info
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?