-
Notifications
You must be signed in to change notification settings - Fork 4.5k
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
Is the locking in ReflectionComposablePart correct? #103650
Comments
Tagging subscribers to this area: @dotnet/area-system-componentmodel-composition |
This is broken. should be checking the field not the local. |
Same issue in Lines 64 to 77 in 93eacbd
|
That one's ok. Note L69. |
omajid
added a commit
to omajid/dotnet-runtime
that referenced
this issue
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: dotnet#103650
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
runtime/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/ReflectionModel/ReflectionComposablePart.cs
Lines 85 to 97 in 93eacbd
https://github.com/dotnet/runtime/blob/main/docs/design/specs/Memory-model.md describes how Object assignment to a location potentially accessible by other threads is a release with respect to accesses to the instance’s fields/elements and metadata. But this method only uses the local variable
value
for locking. Any updates tovalue
will not be seen by other threads. It seems like this might be possible:_importsCache == null
andvalue == null
and enters the first conditional_importsCache == null
andvalue == null
and enters the first conditional toovalue == null
and initializes_importsCache
to a new dictionaryvalue
is still null, and then re-initializes_importsCache
to another value.Is this correct/possible?
The text was updated successfully, but these errors were encountered: