Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix locking in ReflectionComposablePart.ImportsCache #103660

Conversation

omajid
Copy link
Member

@omajid omajid commented Jun 18, 2024

The second check needs to use the value from the field (to see updates made by other threads), not the local variable.

Fixes: #103650

The second check needs to use the value from the field (to see updates
made by other threads), not the local variable.

Fixes: dotnet#103650
@dotnet-policy-service dotnet-policy-service bot added the community-contribution Indicates that the PR has been added by a community member label Jun 18, 2024
Copy link
Contributor

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

@omajid
Copy link
Member Author

omajid commented Jun 18, 2024

Would it be better to re-write ImportsCache and ImportValues to not use the local variable to make it closer to the easier-to-read representation suggested in https://github.com/dotnet/runtime/blob/main/docs/design/specs/Memory-model.md#examples-and-common-patterns under "Singleton (using a lock)"?

@stephentoub
Copy link
Member

Thanks

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-System.ComponentModel community-contribution Indicates that the PR has been added by a community member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Is the locking in ReflectionComposablePart correct?
2 participants