From a399a93c280fa9771cba2afd347ddcb28e16dc40 Mon Sep 17 00:00:00 2001 From: Jason Curl Date: Sat, 1 Feb 2020 12:56:39 +0100 Subject: [PATCH] ThreadDump: Capture Access Denied exceptions 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 --- CrashReporter/CrashData/ThreadDump.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CrashReporter/CrashData/ThreadDump.cs b/CrashReporter/CrashData/ThreadDump.cs index 2e8a373..0e73259 100644 --- a/CrashReporter/CrashData/ThreadDump.cs +++ b/CrashReporter/CrashData/ThreadDump.cs @@ -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; } } }