-
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
Ensure serializer reflection-dependency sentinel is accurate #67104
Ensure serializer reflection-dependency sentinel is accurate #67104
Conversation
Tagging subscribers to this area: @dotnet/area-system-text-json Issue DetailsBackport of #66522 addressing possible race condition introduced by #65898. Customer ImpactThis is an internal find prompted by test failures in our CI matrix. A race condition in static initialization can result in a TestingMerging #66522 in RiskLow.
|
@@ -30,10 +31,10 @@ public sealed partial class JsonSerializerOptions | |||
[RequiresUnreferencedCode(JsonSerializer.SerializationUnreferencedCodeMessage)] | |||
private void RootBuiltInConverters() | |||
{ | |||
if (s_defaultSimpleConverters is null) | |||
if (Volatile.Read(ref s_defaultFactoryConverters) is null) |
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.
I know this could not be a direct backport. So I assume the comments in the main
change do not apply here? https://github.com/dotnet/runtime/pull/66522/files#diff-143351693c2cb653ad82e34086cfd8863b0bda66c8b498ed8a400924c4f5224e
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.
They do, but this is fairly standard use of Volatile so I don't believe it warrants explanation.
This will need our servicing changes added after we do branding for 6.0.5, alternatively we can just do that as part of the branding by leaving |
I think it's better to do it here, for clarity. @eiriktsarpalis you'll just need to bump the runtime/src/libraries/System.Text.Json/src/System.Text.Json.csproj Lines 12 to 13 in 2eb4efb
|
...ries/System.Text.Json/src/System/Text/Json/Serialization/JsonSerializerOptions.Converters.cs
Show resolved
Hide resolved
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This should be merged asap to make the May releases. |
Backport of #66522 addressing possible race condition introduced by #65898.
Customer Impact
This is an internal find prompted by test failures in our CI matrix. A race condition in static initialization can result in a
NullReferenceException
when multiple threads attempt to serialize for the first time. In principle we believe that this issue could also impact 6.0, however differences in the static initialization implementation makes it less likely to occur. I have not been able to reproduce the bug in 6.0 when stress testing for the scenario in question.Testing
Merging #66522 in
main
eliminated any further occurrences of the issue in CI testing.Risk
Low.