benaadams / Ben.Demystifier

High performance understanding for stack traces (Make error logs more productive)
Apache License 2.0
2.76k stars 118 forks source link

The PDB reader occasionally fails with file access exception #70

Open onyxmaster opened 6 years ago

onyxmaster commented 6 years ago
System.IO.IOException: The process cannot access the file 'C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\6dac5fe0\f282cd8a\assembly\dl3\5032d4d4\5885728e_c5e2d301\WebApp.Compiled.pdb' because it is being used by another process.
void System.IO.__Error.WinIOError(int errorCode, string maybeFullPath)
void System.IO.FileStream.Init(string path, FileMode mode, FileAccess access, int rights, bool useRights, FileShare share, int bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, string msgPath, bool bFromProxy, bool useLongPath, bool checkHost)
new System.IO.FileStream(string path, FileMode mode, FileAccess access, FileShare share)
bool System.Diagnostics.Internal.PortablePdbReader.IsPortable(string pdbPath)
MetadataReader System.Diagnostics.Internal.PortablePdbReader.GetMetadataReader(string assemblyPath)
void System.Diagnostics.Internal.PortablePdbReader.PopulateStackFrame(StackFrame frameInfo, MethodBase method, int IlOffset, out string fileName, out int row, out int column)
List<EnhancedStackFrame> System.Diagnostics.EnhancedStackTrace.GetFrames(StackTrace stackTrace)
new System.Diagnostics.EnhancedStackTrace(StackTrace stackTrace)
...

I checked the code for PortablePdbReader and it seems that it opens the files with proper sharing mode (via File.OpenRead), so I have no idea why it can fail or who else could be opening the PDB (this is an ASP.NET 4.5 application running in IIS 8), but I believe I still have to report this. I'm going to place an IOException handler around calls to the Demystifier methods in our code to handle cases like these, and I think you could consider doing the same.