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

Fix JsonDocument thread safety. #76716

Merged

Conversation

eiriktsarpalis
Copy link
Member

Removes the cache breaking JsonDocument's thread safety.

Fixes #76440. Supersedes #76450.

Co-authored-by: stoub@microsoft.com
@ghost
Copy link

ghost commented Oct 6, 2022

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

Removes the cache breaking JsonDocument's thread safety.

Fixes #76440. Supersedes #76450.

Author: eiriktsarpalis
Assignees: -
Labels:

area-System.Text.Json

Milestone: -

@eiriktsarpalis eiriktsarpalis added this to the 8.0.0 milestone Oct 6, 2022
@eiriktsarpalis eiriktsarpalis requested review from krwq and layomia October 6, 2022 15:56
@build-analysis build-analysis bot mentioned this pull request Oct 6, 2022
2 tasks
Copy link
Member

@krwq krwq left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code-wise looks good, please validate if we care about perf of reading same property multiple times (I personally prefer cleaner code to micro-optimizations but we should validate this won't regress perf of some important scenario we might be missing)

@eiriktsarpalis eiriktsarpalis merged commit c141b8a into dotnet:main Oct 11, 2022
@eiriktsarpalis eiriktsarpalis deleted the jsondocument-thread-safety branch October 11, 2022 09:09
@ghost ghost locked as resolved and limited conversation to collaborators Nov 10, 2022
@dotnet dotnet unlocked this conversation Sep 29, 2023
@eiriktsarpalis
Copy link
Member Author

/backport to release/7.0

@github-actions
Copy link
Contributor

Started backporting to release/7.0: https://github.com/dotnet/runtime/actions/runs/6355724177

@eiriktsarpalis
Copy link
Member Author

/backport to release/6.0

@github-actions
Copy link
Contributor

Started backporting to release/6.0: https://github.com/dotnet/runtime/actions/runs/6355726996

@github-actions
Copy link
Contributor

@eiriktsarpalis backporting to release/6.0 failed, the patch most likely resulted in conflicts:

$ git am --3way --ignore-whitespace --keep-non-patch changes.patch

Applying: Fix JsonDocument thread safety.
Using index info to reconstruct a base tree...
M	src/libraries/System.Text.Json/src/System/Text/Json/Document/JsonDocument.cs
M	src/libraries/System.Text.Json/tests/System.Text.Json.Tests/JsonDocumentTests.cs
Falling back to patching base and 3-way merge...
Auto-merging src/libraries/System.Text.Json/tests/System.Text.Json.Tests/JsonDocumentTests.cs
Auto-merging src/libraries/System.Text.Json/src/System/Text/Json/Document/JsonDocument.cs
CONFLICT (content): Merge conflict in src/libraries/System.Text.Json/src/System/Text/Json/Document/JsonDocument.cs
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
Patch failed at 0001 Fix JsonDocument thread safety.
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".
Error: The process '/usr/bin/git' failed with exit code 128

Please backport manually!

@github-actions
Copy link
Contributor

@eiriktsarpalis an error occurred while backporting to release/6.0, please check the run log for details!

Error: git am failed, most likely due to a merge conflict.

@eiriktsarpalis
Copy link
Member Author

/backport to release/6.0-staging

@github-actions
Copy link
Contributor

Started backporting to release/6.0-staging: https://github.com/dotnet/runtime/actions/runs/6355783078

@github-actions
Copy link
Contributor

@eiriktsarpalis backporting to release/6.0-staging failed, the patch most likely resulted in conflicts:

$ git am --3way --ignore-whitespace --keep-non-patch changes.patch

Applying: Fix JsonDocument thread safety.
Using index info to reconstruct a base tree...
M	src/libraries/System.Text.Json/src/System/Text/Json/Document/JsonDocument.cs
M	src/libraries/System.Text.Json/tests/System.Text.Json.Tests/JsonDocumentTests.cs
Falling back to patching base and 3-way merge...
Auto-merging src/libraries/System.Text.Json/tests/System.Text.Json.Tests/JsonDocumentTests.cs
Auto-merging src/libraries/System.Text.Json/src/System/Text/Json/Document/JsonDocument.cs
CONFLICT (content): Merge conflict in src/libraries/System.Text.Json/src/System/Text/Json/Document/JsonDocument.cs
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
Patch failed at 0001 Fix JsonDocument thread safety.
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".
Error: The process '/usr/bin/git' failed with exit code 128

Please backport manually!

@github-actions
Copy link
Contributor

@eiriktsarpalis an error occurred while backporting to release/6.0-staging, please check the run log for details!

Error: git am failed, most likely due to a merge conflict.

@eiriktsarpalis
Copy link
Member Author

/backport to release/7.0-staging

@github-actions
Copy link
Contributor

Started backporting to release/7.0-staging: https://github.com/dotnet/runtime/actions/runs/6355857882

eiriktsarpalis added a commit to eiriktsarpalis/runtime that referenced this pull request Sep 29, 2023
Co-authored-by: stoub@microsoft.com
ericstj pushed a commit that referenced this pull request Sep 30, 2023
* Fix JsonDocument thread safety. (#76716)

Co-authored-by: stoub@microsoft.com

* Update ServicingVersion.
@ghost ghost locked as resolved and limited conversation to collaborators Oct 29, 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.

JsonDocument.GetString implementation is not thread safe
2 participants