-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Fix XamlDirective stack overflow exception #10314
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
base: main
Are you sure you want to change the base?
Fix XamlDirective stack overflow exception #10314
Conversation
Wouldn't it be enough if you did private static MemberReflector s_UnknownReflector;
internal static MemberReflector UnknownReflector => s_UnknownReflector ??= CreateUnknownReflector(); |
Is there a reason why we're not keeping lazy-init, just making it TS instead? |
It was lazy because static fields only get assigned when necessary and in this case CreateUnknownReflector was only called on the first call to UnknownReflector and it was thread-safe because static constructors are thread safe. I pushed a commit to change it to make the lazy init explicit and more clear. |
…ective-stack-overflow-exception # Conflicts: # src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Xaml/Schema/MemberReflector.cs
I pulled main to fix the conflicts. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #10314 +/- ##
===================================================
+ Coverage 11.45872% 11.54691% +0.08819%
===================================================
Files 3214 3214
Lines 648458 648459 +1
Branches 71511 71511
===================================================
+ Hits 74305 74877 +572
+ Misses 572989 572330 -659
- Partials 1164 1252 +88
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
Fixes #10313
Description
I changed MemberReflector.UnknownReflector to be thread safe by initializing the property from the static constructor instead of doing the lazy initialization manually. The static constructor of a type is guaranteed to be called only once.
See the issue for an explanation of the bug and how it's hit.
Customer Impact
Could fix a crash or weird behavior at runtime but it's very hard to hit (See issue).
Regression
No.
Testing
Used the repro in the issue which crashed before this PR and passes with this PR.
Risk
Low.
Microsoft Reviewers: Open in CodeFlow