Skip to content

Don't report a interp->native transition when it is done from a pinvoke method#127660

Merged
BrzVlad merged 1 commit intodotnet:mainfrom
BrzVlad:fix-clrinterp-profiler-transitions
May 2, 2026
Merged

Don't report a interp->native transition when it is done from a pinvoke method#127660
BrzVlad merged 1 commit intodotnet:mainfrom
BrzVlad:fix-clrinterp-profiler-transitions

Conversation

@BrzVlad
Copy link
Copy Markdown
Member

@BrzVlad BrzVlad commented May 1, 2026

We didn't report these transitions when they were triggered from ILStubs because they already explicitly do this. Following the change of using transient IL belonging to the actual PInvoke method rather than separate ILStub methods (which should contain the same logic as the ILStub used to), we would now report the same event twice. We need therefore to also ignore the case where we are doing a PInvoke call from an actual PInvoke method.

Fixes src/tests/profiler/transitions/transitions.csproj which regressed after #126509 on interpreter.

…ke method

We didn't report these transitions when they were triggered from ILStubs because they already explicitly do this. Following the change of using transient IL belonging to the actual PInvoke method rather than separate ILStub methods (which should contain the same logic as the ILStub used to), we would now report the same event twice. We need therefore to also ignore the case where we are doing a PInvoke call from an actual PInvoke method.

Fixes src/tests/profiler/transitions/transitions.csproj.
Copilot AI review requested due to automatic review settings May 1, 2026 19:41
@BrzVlad BrzVlad requested review from janvorli and kg as code owners May 1, 2026 19:41
@BrzVlad BrzVlad requested a review from jkoritzinsky May 1, 2026 19:41
@BrzVlad
Copy link
Copy Markdown
Member Author

BrzVlad commented May 1, 2026

/azp run runtime-interpreter

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@dotnet-policy-service
Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @JulieLeeMSFT, @BrzVlad, @janvorli, @kg
See info in area-owners.md if you want to be subscribed.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 adjusts CoreCLR interpreter profiling transition reporting to avoid double-counting managed↔unmanaged transition events when the interpreter executes transient-IL-backed P/Invoke methods (post-#126509). This restores expected behavior for profiler transition tests by suppressing interpreter-side transition callbacks in cases where the P/Invoke body already performs the transition notifications.

Changes:

  • Suppress ProfilerManagedToUnmanagedTransitionMD / ProfilerUnmanagedToManagedTransitionMD callbacks in the interpreter calli-with-transition path when the currently interpreted method is a P/Invoke.
  • Preserve the existing suppression for IL stubs, extending it to P/Invoke methods now that the transient IL is attributed to the P/Invoke MethodDesc.

@BrzVlad BrzVlad merged commit 11a3209 into dotnet:main May 2, 2026
126 of 132 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants