Skip to content

Fix GCStats failures on dotnet trace gc-verbose collections (#2414)#2415

Merged
brianrob merged 1 commit into
microsoft:mainfrom
cincuranet:fix-jared
Apr 24, 2026
Merged

Fix GCStats failures on dotnet trace gc-verbose collections (#2414)#2415
brianrob merged 1 commit into
microsoft:mainfrom
cincuranet:fix-jared

Conversation

@cincuranet
Copy link
Copy Markdown
Collaborator

Two issues prevented the GCStats report from opening for traces collected via dotnet trace --profile gc-verbose:

  1. PrintEventCondemnedReasonsTable in GcStats.cs threw NullReferenceException because GetCondemnedReasonRow returns null when a TraceGC has neither PerHeapCondemnedReasons nor GlobalCondemnedReasons. Skip such events instead of adding null rows to the table.

  2. AddConcurrentPauseTime in TraceManagedProcess.cs had a Debug.Assert(_event.PauseDurationMSec == 0) that was always wrong for BackgroundGCs: the GCStart handler intentionally pre-seeds PauseDurationMSec = SuspendDurationMSec for BGCs, so by the time the initial RestartEEStop fires the value is non-zero by design. The else branch's assignment then correctly replaces it with the full pause. Remove the bogus assertion.

Fixes #2414

…t#2414)

Two issues prevented the GCStats report from opening for traces collected via `dotnet trace --profile gc-verbose`:

1. `PrintEventCondemnedReasonsTable` in `GcStats.cs` threw NullReferenceException because `GetCondemnedReasonRow` returns null when a TraceGC has neither PerHeapCondemnedReasons nor GlobalCondemnedReasons. Skip such events instead of adding null rows to the table.

2. `AddConcurrentPauseTime` in `TraceManagedProcess.cs` had a `Debug.Assert(_event.PauseDurationMSec == 0)` that was always wrong for BackgroundGCs: the GCStart handler intentionally pre-seeds `PauseDurationMSec = SuspendDurationMSec` for BGCs, so by the time the initial RestartEEStop fires the value is non-zero by design. The else branch's assignment then correctly replaces it with the full pause. Remove the bogus assertion.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@cincuranet cincuranet requested a review from a team as a code owner April 23, 2026 11:54
Copy link
Copy Markdown
Member

@brianrob brianrob left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

NullReferenceException opening the GC stats view

2 participants