Skip to content

Conversation

@github-actions
Copy link
Contributor

@github-actions github-actions bot commented Sep 22, 2025

Backport of #117523 to release/9.0-staging

/cc @AaronRobinsonMSFT

Fixes #119947

Customer Impact

  • Customer reported
  • Found internally

See confirmation the fix addressed the issue in .NET 10 and the OP is requesting backport to .NET 9 - #119947. The original issue can be found at #112565.

The setting of the PInvokeMethodDesc::kPInvokePopulated bit is done via an interlocked operation. This bit is used to indicate if the PInvokeMethodDesc has been populated with the needed information to load the P/Invoke. The reading of this bit however was missing an acquire barrier and thus setting of fields between the check and set weren't being observed correctly.

Regression

  • Yes
  • No

It isn't obvious when this was likely introduced, but it is likely been in the code base for many years. It was likely uncovered by refactors of PInvoke code paths.

Testing

This was checked in .NET 10 and the external user has been running without observing a crash for several weeks.

Risk

Low. This has been running in .NET 10 preview for several weeks and an external user has been running with these bits without observing the issue.

The setting of the NDirectMethodDesc::kNDirectPopulated bit
is done via an interlocked operation. This bit is used to indicate
if the NDirectMethodDesc has been populated with the needed
information to load the P/Invoke. The reading of this bit however
was missing an acquire barrier and thus setting of fields between
the check and set weren't being observed correctly.
@AaronRobinsonMSFT AaronRobinsonMSFT added this to the 9.0.x milestone Sep 22, 2025
@AaronRobinsonMSFT AaronRobinsonMSFT added the Servicing-consider Issue for next servicing release review label Sep 22, 2025
@dotnet-policy-service
Copy link
Contributor

Tagging subscribers to this area: @dotnet/interop-contrib
See info in area-owners.md if you want to be subscribed.

@rbhanda rbhanda modified the milestones: 9.0.x, 9.0.11 Sep 23, 2025
@rbhanda rbhanda added Servicing-approved Approved for servicing release and removed Servicing-consider Issue for next servicing release review labels Sep 23, 2025
@AaronRobinsonMSFT
Copy link
Member

/ba-g unrelelated timeouts

@AaronRobinsonMSFT AaronRobinsonMSFT merged commit 979542f into release/9.0-staging Sep 24, 2025
94 of 102 checks passed
@AaronRobinsonMSFT AaronRobinsonMSFT deleted the backport/pr-117523-to-release/9.0-staging branch September 24, 2025 17:02
@github-actions github-actions bot locked and limited conversation to collaborators Oct 25, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-Interop-coreclr Servicing-approved Approved for servicing release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants