Skip to content

Special case object pool redirection#12308

Merged
chsienki merged 1 commit intodotnet:mainfrom
chsienki:objectpool_redirect
Oct 9, 2025
Merged

Special case object pool redirection#12308
chsienki merged 1 commit intodotnet:mainfrom
chsienki:objectpool_redirect

Conversation

@chsienki
Copy link
Member

@chsienki chsienki commented Oct 9, 2025

  • Don't redirect to the shared VS copy
  • Redirect to the copy that is next to the compiler
  • This ensures that both tooling and roslyn can find the same assemblies

See embedded comment for a detailed description of the problem and why this fixes it.

Fixes https://devdiv.visualstudio.com/DevDiv/_queries/edit/2595643 (AKA Race condition 2)

@chsienki chsienki requested a review from a team as a code owner October 9, 2025 22:52
- Don't redirect to the shared VS copy
- Redirect to the copy that is next to the compiler
- This ensures that both tooling and roslyn can find the same assemblies

See embedded comment for a detailed description of the problem and why this fixes it.
@chsienki chsienki force-pushed the objectpool_redirect branch from af81402 to 71e1f1a Compare October 9, 2025 22:53
Copy link
Member

@davidwengier davidwengier left a comment

Choose a reason for hiding this comment

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

Excellent comment!

The only thing this doesn't really answer for me is why it started happening so much more often, or was it just because the default for the source generator suppression changed?

@chsienki
Copy link
Member Author

chsienki commented Oct 9, 2025

@davidwengier Yeah, we changed the default.

Previously, when Roslyn loaded first the other race condition would ensure that the generator is suppressed. That means it doesn't really touch any of the actual generator code and doesn't load ObjectPool. Razor would then load and actually load the rest of the compiler assemblies, including ObjectPool. The first race condition would eventually unstick itself and the generator would use the assemblies loaded by razor.

So this race condition was effectively being avoided by the suppression race condition acting as a loader lock 😆

@chsienki chsienki enabled auto-merge (squash) October 9, 2025 23:13
@chsienki
Copy link
Member Author

chsienki commented Oct 9, 2025

/backport to release/dev18.0

@github-actions
Copy link
Contributor

github-actions bot commented Oct 9, 2025

Started backporting to release/dev18.0: https://github.com/dotnet/razor/actions/runs/18391573119

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants