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

Ensure that JsonSerializerOptions.CacheContext is a singleton. #94527

Merged

Conversation

eiriktsarpalis
Copy link
Member

Fixes a race condition wherein the JsonSerializerOptions.CacheContext property could be returning multiple instances, which can occasionally make this assertion fail:

Debug.Assert(Monitor.IsEntered(Options.CacheContext), "Configure called directly, use EnsureConfigured which synchronizes access to this method");

Fix #88102.

@ghost
Copy link

ghost commented Nov 8, 2023

Tagging subscribers to this area: @dotnet/area-system-text-json, @gregsdennis
See info in area-owners.md if you want to be subscribed.

Issue Details

Fixes a race condition wherein the JsonSerializerOptions.CacheContext property could be returning multiple instances, which can occasionally make this assertion fail:

Debug.Assert(Monitor.IsEntered(Options.CacheContext), "Configure called directly, use EnsureConfigured which synchronizes access to this method");

Fix #88102.

Author: eiriktsarpalis
Assignees: eiriktsarpalis
Labels:

area-System.Text.Json

Milestone: -

@eiriktsarpalis eiriktsarpalis added this to the 9.0.0 milestone Nov 8, 2023
@eiriktsarpalis eiriktsarpalis merged commit 57fd56a into dotnet:main Nov 15, 2023
@eiriktsarpalis eiriktsarpalis deleted the fix-cachingcontext-uniqueness branch November 15, 2023 18:27
@github-actions github-actions bot locked and limited conversation to collaborators Dec 16, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Native crash on System.Text.Json.SourceGeneration.Roslyn4.4.Tests net8.0-linux-Debug-arm64-Mono_release
2 participants