-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Call TypeDescriptor.GetProperties before calling Refresh in ReflectionCachesUpdateHandler #51604
Conversation
Tagging subscribers to this area: @safern Issue DetailsTry to fix #51588 According to the docs: Counterintuitive, but ok. cc: @jeffhandley, @safern
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm interesting 😕
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Any idea why it was only failing on macOS?
My guess is the failures are happening when this test runs concurrently with some other test, and without the GetProperties call, Refresh ends up not being thread-safe. At least that's my very limited understanding from the docs and a quick perusal of the source. If that's true, then this isn't limited to just macOS, and that's simply the only place we've seen it so far. |
Seems like a reasonable hunch. Thanks for addressing it so swiftly! |
…nCachesUpdateHandler
bcfca50
to
592e90e
Compare
Looks like it's also failed in Linux now so not Mac specific |
And also not fixed by this change. It's possible TypeDescriptor.Refresh simply isn't thread-safe, violating rules around statics in .NET. I'll need to look deeper. |
TypeDescriptor.Refresh isn't thread-safe, trying to enumerate a hashtable that's concurrently mutated, leading to a concurrent modification exceptions. We'll need to decide if we're ok with the limitation or if we need to do surgery on TypeDescriptor to fix it.
Try to fix #51588
According to the docs:
"Before you make a call to the Refresh method to clear the cache, you need to call the GetProperties method for the specific assembly to cache the information first."
Counterintuitive, but ok.
cc: @jeffhandley, @safern