Skip to content

Commit

Permalink
ThreadDump: Capture Access Denied exceptions
Browse files Browse the repository at this point in the history
When doing a dump within a Control-C handler under Windows, dumping threads may result in an UnauthorizedAccessException "Access is denied" when capturing the native threads PriorityLevel, or "System.ComponentModel.Win32Exception (0x80004005): Access is denied" when capturing the user time, or total time.

If those exceptions occur, just abort the capture, but we still log what ever information was available up until the exception.

Issue: HELIOS-1350
  • Loading branch information
jcurl committed Feb 1, 2020
1 parent a3c2974 commit a399a93
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion CrashReporter/CrashData/ThreadDump.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,12 @@ protected override bool UpdateRow(ProcessThread item, DumpRow row)
row[ThreadPrio] = item.PriorityLevel.ToString();
row[ThreadUserTime] = item.UserProcessorTime.TotalSeconds.ToString();
row[ThreadTotalTime] = item.TotalProcessorTime.TotalSeconds.ToString();
return true;
} catch (AccessViolationException) { // Ignore: Access denied
} catch (System.ComponentModel.Win32Exception) { // Ignore: Access denied
} catch (InvalidOperationException) {
return false;
}
return true;
}
}
}

0 comments on commit a399a93

Please sign in to comment.