Skip to content

Fix profiler GC heap enumeration on external threads - #132644

Merged
noahfalk merged 1 commit into
mainfrom
copilot/fix-gcheapenumeration-test-failure
Aug 24, 2026
Merged

noahfalk merged 1 commit into
mainfrom
copilot/fix-gcheapenumeration-test-failure

Conversation

Copilot AI commented Aug 21, 2026 •

Copy link
Copy Markdown
Contributor

main PR

Description

EnumerateGCHeapObjects misidentified an external profiler thread as the suspension thread when both thread pointers were null, returning CORPROF_E_SUSPENSION_IN_PROGRESS.

  • Suspension ownership: Require a managed current thread before treating it as the suspension owner.
bool suspendedByThisThread =
    pCurrentThread != nullptr &&
    ThreadSuspend::GetSuspensionThread() == pCurrentThread;

Customer Impact

Profiler heap enumeration during server GC can fail spuriously.

Regression

Unknown.

Testing

Existing gcheapenumeration coverage exercises the competing runtime-suspension path.

Risk

Low. The change only distinguishes two null thread pointers from actual suspension ownership.

Package authoring no longer needed in .NET 9

IMPORTANT: Starting with .NET 9, you no longer need to edit a NuGet package's csproj to enable building and bump the version.
Keep in mind that we still need package authoring in .NET 8 and older versions.

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
16 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

Copilot AI changed the title [WIP] Fix gcheapenumeration.cmd test failure in CI Fix profiler GC heap enumeration on external threads Aug 21, 2026
Copilot AI requested a review from noahfalk August 21, 2026 22:49
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @steveisok, @tommcdon, @dotnet/dotnet-diag
See info in area-owners.md if you want to be subscribed.

@noahfalk
noahfalk marked this pull request as ready for review August 22, 2026 03:38
Copilot AI lite review requested due to automatic review settings August 22, 2026 03:38
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).
13 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

@noahfalk
noahfalk enabled auto-merge (squash) August 22, 2026 03:41

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a correctness bug in CoreCLR’s profiler heap enumeration path where an external (non-managed) profiler thread could be incorrectly treated as the runtime suspension owner when both thread pointers were nullptr, causing EnumerateGCHeapObjects to spuriously return CORPROF_E_SUSPENSION_IN_PROGRESS.

Changes:

  • Capture GetThreadNULLOk() into a local and require it to be non-null before considering the current thread the suspension owner.
  • Prevent the nullptr == nullptr comparison from triggering the “suspension owner” fast-fail path.

Copilot AI review requested due to automatic review settings August 22, 2026 20:41
@noahfalk
noahfalk force-pushed the copilot/fix-gcheapenumeration-test-failure branch from f416e96 to 5899072 Compare August 22, 2026 20:41

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

@noahfalk
noahfalk merged commit 113dfc8 into main Aug 24, 2026
102 checks passed
@noahfalk
noahfalk deleted the copilot/fix-gcheapenumeration-test-failure branch August 24, 2026 15:40
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 12.0-preview1 milestone Aug 25, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators Sep 24, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

profiler/gcheapenumeration/gcheapenumeration/gcheapenumeration.cmd fails in CI

6 participants