Skip to content

[CoreCLR] Protect exception object across funclet callbacks - #132482

Merged
steveisok merged 3 commits into
mainfrom
steveisok-fix-exception-funclet-gc
Aug 19, 2026
Merged

steveisok merged 3 commits into
mainfrom
steveisok-fix-exception-funclet-gc

Conversation

@steveisok

Copy link
Copy Markdown
Member

Fixes #132462

Summary

  • Protect the exception OBJECTREF in CallFilterFunclet and CallCatchFunclet while profiler, debugger, and ETW callbacks may permit GC, through the subsequent funclet invocation.
  • Extend the existing exception profiler test to exercise both filter and catch funclet paths while exception monitoring is enabled.

Testing

  • Confirmed the regression test fail-fasts against the unfixed checked runtime.
  • Built CoreCLR checked successfully with no warnings or errors.
  • Ran the targeted ExceptionTest against the fixed checked runtime; it returned 100 and reported PROFILER TEST PASSES.

Note

This description was generated with GitHub Copilot.

Co-authored-by: Copilot App <[email protected]>

Copilot-Session: d1145d75-6c1d-4d53-8793-ea41900a04ca
Copilot AI lite review requested due to automatic review settings August 18, 2026 19:05
@github-actions github-actions Bot added the area-ExceptionHandling-coreclr only use for closed issues label Aug 18, 2026
@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.

@steveisok
steveisok requested review from a team and janvorli August 18, 2026 19:06

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 GC-safety bug in CoreCLR exception handling by protecting the active exception OBJECTREF across profiler/debugger/ETW callbacks and the subsequent filter/catch funclet invocation, preventing checked-build asserts when profilers enable exception monitoring.

Changes:

  • Add GCPROTECT_BEGIN/END around throwable in CallCatchFunclet to keep the exception object GC-visible across callbacks and CallFunclet.
  • Add GCPROTECT_BEGIN/END around throwable in CallFilterFunclet for the same reason.
  • Extend the existing exception profiler test to execute both filter and catch paths and validate the additional ExceptionSearchFilter* events in the expected sequence.

Note: I did not run builds/tests in this review; assessment is based on code inspection and the PR’s stated testing.

Show a summary per file
File Description
src/coreclr/vm/exceptionhandling.cpp Protects the exception object with GCPROTECT across callback regions and funclet calls in filter/catch execution paths.
src/tests/profiler/exception/ExceptionTest.cs Adds an exception filter to exercise filter + catch funclets and updates expected profiler callback sequence accordingly.

Review details

  • Files reviewed: 2/2 changed files
  • Comments generated: 0
  • Review effort level: Lite

Comment thread src/coreclr/vm/exceptionhandling.cpp Resolved
Comment thread src/coreclr/vm/exceptionhandling.cpp Resolved
Copilot AI review requested due to automatic review settings August 19, 2026 13:06
Comment thread src/coreclr/vm/exceptionhandling.cpp Resolved
Comment thread src/coreclr/vm/exceptionhandling.cpp Resolved
Comment thread src/coreclr/vm/exceptionhandling.cpp Resolved

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.

Review details

  • Files reviewed: 2/2 changed files
  • Comments generated: 1
  • Review effort level: Lite

Comment thread src/coreclr/vm/exceptionhandling.cpp Resolved
Comment thread src/coreclr/vm/exceptionhandling.cpp Resolved
Co-authored-by: Copilot App <[email protected]>

Copilot-Session: 6a0f5fb2-4a96-4a7e-8f6a-37bb262a1401
Copilot AI review requested due to automatic review settings August 19, 2026 13:46

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.

Review details

Suppressed comments (1)

src/coreclr/vm/exceptionhandling.cpp:3368

  • This introduces an unused unprotected OBJECTREF local right before ExInfo::PopExInfos. On the pHandlerIP == NULL path, this function can later enter GCX_PREEMP_NO_DTOR() (e.g., in the UNIX propagation-callback path), which risks the same stale-OBJECTREF assert from #132462. Since the value isn’t used, it should be removed rather than kept live across GC-mode transitions.
    OBJECTREF throwable = exInfo->GetThrowable();
  • Files reviewed: 2/2 changed files
  • Comments generated: 1
  • Review effort level: Lite

Comment thread src/coreclr/vm/exceptionhandling.cpp Resolved
@steveisok
steveisok merged commit 293d2c1 into main Aug 19, 2026
108 checks passed
@steveisok
steveisok deleted the steveisok-fix-exception-funclet-gc branch August 19, 2026 19:37
@steveisok

Copy link
Copy Markdown
Member Author

/backport to release/11.0-rc1

@github-actions

Copy link
Copy Markdown
Contributor

Started backporting to release/11.0-rc1 (link to workflow run)

@kg-unity3d

Copy link
Copy Markdown

Thank you!

steveisok added a commit that referenced this pull request Aug 20, 2026
…callbacks (#132532)

Backport of #132482 to release/11.0-rc1

/cc @steveisok

## Customer Impact

- [ ] Customer reported
- [ ] Found internally

[Select one or both of the boxes. Describe how this issue impacts
customers, citing the expected and actual behaviors and scope of the
issue. If customer-reported, provide the issue number.]

## Regression

- [ ] Yes
- [ ] No

[If yes, specify when the regression was introduced. Provide the PR or
commit if known.]

## Testing

[How was the fix verified? How was the issue missed previously? What
tests were added?]

## Risk

[High/Medium/Low. Justify the indication by mentioning how risks were
measured and addressed.]

**IMPORTANT**: If this backport is for a servicing release, please
verify that:

- For .NET 8 and .NET 9: The PR target branch is `release/X.0-staging`,
not `release/X.0`.
- For .NET 10+: The PR target branch is `release/X.0` (no `-staging`
suffix).

## 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.

Co-authored-by: Steve Pfister <[email protected]>
Co-authored-by: Copilot App <[email protected]>
Copilot-Session: d1145d75-6c1d-4d53-8793-ea41900a04ca
Copilot-Session: 6a0f5fb2-4a96-4a7e-8f6a-37bb262a1401
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 12.0-preview1 milestone Aug 21, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators Sep 20, 2026
@janvorli

Copy link
Copy Markdown
Member

/backport to release/10.0

@github-actions github-actions Bot unlocked this conversation Oct 30, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Started backporting to release/10.0 (link to workflow run)

@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Oct 30, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-ExceptionHandling-coreclr only use for closed issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unprotected OBJECTREF in CallFilterFunclet asserts when a profiler monitors exceptions

6 participants