Skip to content

Fix VSD cache publication and resolve stub size - #134226

Open
davidwrighton with Copilot wants to merge 1 commit into
mainfrom
copilot/virtual-stub-dispatch-review
Open

davidwrighton with Copilot wants to merge 1 commit into
mainfrom
copilot/virtual-stub-dispatch-review

Conversation

Copilot AI commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Publish virtual stub dispatch cache entries with VolatileStore so initialized entries are safely visible to concurrent readers.
  • Correct ResolveStub::size() to return sizeof(ResolveStub) instead of sizeof(LookupStub).

Co-authored-by: davidwrighton <10779849+davidwrighton@users.noreply.github.com>
@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.

@davidwrighton

Copy link
Copy Markdown
Member

@copilot , give the PR a good description.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @agocke
See info in area-owners.md if you want to be subscribed.

Copilot AI commented Sep 18, 2026

Copy link
Copy Markdown
Contributor Author

@copilot , give the PR a good description.

Updated the PR description with the two root causes, the fixes, scope separation for the counter work, and validation performed.

@davidwrighton

Copy link
Copy Markdown
Member

@copilot, update the PR description for pull #134226

@davidwrighton davidwrighton changed the title Reviewing correctness of virtual stub dispatch implementation Fix VSD cache publication and resolve stub size Sep 19, 2026
@davidwrighton
davidwrighton marked this pull request as ready for review September 19, 2026 00:07
Copilot AI lite review requested due to automatic review settings September 19, 2026 00:07
@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.

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.

Copilot review overview

🔵 Needs a closer look

The changes touch low-level VM concurrency and stub code size accounting where subtle memory-ordering or codegen interactions merit final human validation.

Review effort: Lite
Findings: None

What changed in this PR

This PR makes two targeted correctness fixes in CoreCLR’s Virtual Stub Dispatch (VSD) implementation: it strengthens the publication semantics for dispatch cache entries to support concurrent readers, and it corrects the reported size of the AMD64 resolve stub to match the actual stub type.

Changes:

  • Publish DispatchCache entries with VolatileStore (paired with existing VolatileLoad reads) to ensure initialized cache entries become safely visible to concurrent lookups.
  • Fix ResolveStub::size() on AMD64 to return sizeof(ResolveStub) (matching other architectures and ensuring instruction-cache flush / logging uses the correct byte size).
File Description
src/​coreclr/​vm/​virtualcallstub.h Uses VolatileStore(&cache[idx], elem) for cache entry publication to match VolatileLoad readers.
src/​coreclr/​vm/​amd64/​virtualcallstubcpu.hpp Corrects ResolveStub::size() to return sizeof(ResolveStub) instead of sizeof(LookupStub).

@jkotas

jkotas commented Sep 19, 2026

Copy link
Copy Markdown
Member

Is this a fix for a crash or is this just based on codereview?

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.

4 participants