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

System.Text.Json will attempt to dispose IAsyncEnumerators on exception while there are pending MoveNextAsync operations #57360

Closed
eiriktsarpalis opened this issue Aug 13, 2021 · 3 comments · Fixed by #57505
Assignees
Labels
area-System.Text.Json bug Priority:2 Work that is important, but not critical for the release
Milestone

Comments

@eiriktsarpalis
Copy link
Member

Related to #51176 (comment). Compiler-generated async enumerators will throw NotSupportedException if an attempt is made to dispose them while a MoveNextAsync() task is pending completion. It would seem like STJ is doing this when serialization is cancelled due to a cancellation token firing. It's a bug and we need to fix it.

Originally posted by @eiriktsarpalis in dotnet/aspnetcore#35330 (comment)

cc @davidfowl @stephentoub

@dotnet-issue-labeler
Copy link

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

@dotnet-issue-labeler dotnet-issue-labeler bot added the untriaged New issue has not been triaged by the area owner label Aug 13, 2021
@ghost
Copy link

ghost commented Aug 13, 2021

Tagging subscribers to this area: @eiriktsarpalis, @layomia
See info in area-owners.md if you want to be subscribed.

Issue Details

Related to #51176 (comment). Compiler-generated async enumerators will throw NotSupportedException if an attempt is made to dispose them while a MoveNextAsync() task is pending completion. It would seem like STJ is doing this when serialization is cancelled due to a cancellation token firing. It's a bug and we need to fix it.

Originally posted by @eiriktsarpalis in dotnet/aspnetcore#35330 (comment)

cc @davidfowl @stephentoub

Author: eiriktsarpalis
Assignees: -
Labels:

area-System.Text.Json, untriaged

Milestone: -

@eiriktsarpalis eiriktsarpalis self-assigned this Aug 13, 2021
@eiriktsarpalis eiriktsarpalis removed the untriaged New issue has not been triaged by the area owner label Aug 13, 2021
@eiriktsarpalis eiriktsarpalis added this to the 6.0.0 milestone Aug 13, 2021
@eiriktsarpalis eiriktsarpalis added the Priority:2 Work that is important, but not critical for the release label Aug 13, 2021
@eiriktsarpalis
Copy link
Member Author

eiriktsarpalis commented Aug 13, 2021

See dotnet/aspnetcore#35330 (comment) for the original report. Issue related to #50851.

eiriktsarpalis added a commit to eiriktsarpalis/runtime that referenced this issue Aug 16, 2021
…Disposable instances are disposed exactly once.

Fixes dotnet#57360.
@ghost ghost added the in-pr There is an active PR which will close this issue when it is merged label Aug 16, 2021
eiriktsarpalis added a commit that referenced this issue Aug 17, 2021
* Ensure WriteStack.Pending task is awaited on exception. Ensure IAsyncDisposable instances are disposed exactly once.

Fixes #57360.

* Update src/libraries/System.Text.Json/tests/Common/CollectionTests/CollectionTests.AsyncEnumerable.cs
@ghost ghost removed the in-pr There is an active PR which will close this issue when it is merged label Aug 17, 2021
@ghost ghost locked as resolved and limited conversation to collaborators Sep 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-System.Text.Json bug Priority:2 Work that is important, but not critical for the release
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant