Skip to content

Commit

Permalink
Merge pull request #73790 from jasonmalinowski/fix-nullref-during-shu…
Browse files Browse the repository at this point in the history
…tdown

Copy the ITelemetryReporter to a local before using
  • Loading branch information
jasonmalinowski authored May 31, 2024
2 parents c11fc36 + fde8c37 commit e0abd64
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,14 @@ private static void ReportFault(Exception exception, ErrorSeverity severity, boo
return;
}

if (_telemetryReporter is not null)
// Copy locally, as otherwise if we report a fault during shutdown we might also null reference (and then fatally crash the process)
var telemetryReporter = _telemetryReporter;
if (telemetryReporter is not null)
{
var eventName = GetEventName(FunctionId.NonFatalWatson);
var description = GetDescription(exception);
var currentProcess = Process.GetCurrentProcess();
_telemetryReporter.ReportFault(eventName, description, (int)severity, forceDump, currentProcess.Id, exception);
telemetryReporter.ReportFault(eventName, description, (int)severity, forceDump, currentProcess.Id, exception);
}
}
catch (OutOfMemoryException)
Expand Down

0 comments on commit e0abd64

Please sign in to comment.