Skip to content

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

Open
cincuranet wants to merge 1 commit intomicrosoft:mainfrom
cincuranet:fix-jared
Open

Fix GCStats failures on dotnet trace gc-verbose collections (#2414)#2415
cincuranet wants to merge 1 commit intomicrosoft: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
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

1 participant