Repository navigation
Fix JsonArray lazy list initialization race - #136136
Merged
eiriktsarpalis merged 2 commits intoOct 22, 2026
Merged
Conversation
JsonArray.InitializeList() published _list with a plain store, so threads racing on first access could each build and return their own list. Losing threads got child nodes whose Parent is the array but which are not contained in it: GetPath() reports a bogus index and ReplaceWith() fails to locate the node. Publish the list with Interlocked.CompareExchange and have losing threads adopt the winner's list, matching the fix made for JsonObject in dotnet#120619. Add tests that access a freshly parsed JsonArray from many threads at once and verify every thread observes the child instance stored in the array, with the correct path. Fixes dotnet#136117
|
Azure Pipelines: Successfully started running 3 pipeline(s). 13 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
|
Tagging subscribers to this area: @dotnet/area-system-text-json |
Contributor
Author
|
@dotnet-policy-service agree |
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 69ebdec0-7c63-4cbb-b25c-6d2232145ccc
eiriktsarpalis
approved these changes
Oct 20, 2026
Contributor
Author
|
@eiriktsarpalis I noticed that you have deleted the "is thread safe test" for the json array. Should I also kill the similar one that in JsonObject tests since new test covers both? I've copied my one from there |
EgorBo
approved these changes
Oct 22, 2026
Member
|
/ba-g test failures unrelated. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes race on lazy initialization in JsonArray. Copies fix from (JsonObject)
Added tests to catch it too
Resolves #136117