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

Possible race conditions in WeakReference<T>.SetTarget #25881

Closed
sharwell opened this issue Apr 2, 2018 · 1 comment
Closed

Possible race conditions in WeakReference<T>.SetTarget #25881

sharwell opened this issue Apr 2, 2018 · 1 comment

Comments

@sharwell
Copy link
Member

sharwell commented Apr 2, 2018

The following two cases may suffer from race conditions in the use of WeakReference<T>, similar to the one described in #25839.

var weakReference = new WeakReference<SemanticModel>(speculativeSemanticModel);
var cached = nodeMap.GetValue(newMember, _ => weakReference);
if (cached.TryGetTarget(out var cachedModel))
{
return cachedModel;
}
// oops. somebody has beaten me, but the model has gone.
// set me as new target
cached.SetTarget(speculativeSemanticModel);
return speculativeSemanticModel;

@CyrusNajmabadi
Copy link
Member

Closing out as this has been rewritten and does not use weakrefs anymore.

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

No branches or pull requests

3 participants