-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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 ReadBufferState dispose cases #110739
Fix ReadBufferState dispose cases #110739
Conversation
What leaks? |
If |
...s/System.Text.Json/src/System/Text/Json/Serialization/Metadata/JsonTypeInfoOfT.ReadHelper.cs
Outdated
Show resolved
Hide resolved
…ion/Metadata/JsonTypeInfoOfT.ReadHelper.cs
This is the code for runtime/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/ReadStack.cs Lines 96 to 110 in db9a4c6
And this is the code for the runtime/src/libraries/System.Text.Json/src/System/Text/Json/Reader/JsonReaderState.cs Lines 39 to 54 in db9a4c6
Excluding potential bugs in the underlying implementation(s), neither of these calls are expected to throw. Is there a real-world scenario that could result in unreturned buffers? FWIW I don't think we couldn't consider this change, but to make things more explicit I would just move the initialization methods inside the |
Moved ReadBufferState initialization under try clause. |
That's not quite that I meant. My suggestion was to either keep the current order (but nest the initialization methods inside the |
Initial change was returned with comment |
@dotnet-policy-service agree |
src/libraries/System.Text.Json/src/System/Text/Json/Serialization/JsonSerializer.Read.Stream.cs
Outdated
Show resolved
Hide resolved
...s/System.Text.Json/src/System/Text/Json/Serialization/Metadata/JsonTypeInfoOfT.ReadHelper.cs
Outdated
Show resolved
Hide resolved
...s/System.Text.Json/src/System/Text/Json/Serialization/Metadata/JsonTypeInfoOfT.ReadHelper.cs
Outdated
Show resolved
Hide resolved
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.
Thanks
Is this normal for check "runtime (Build browser-wasm linux Release LibraryTests)" to be running so long? Or may be it is stuck? |
It happens from time to time, I've merged main to retrigger a run. |
I moved the initialization of ReadBufferState after other related operations to prevent skipping Dispose in case of an exception, and consequently, to avoid memory leaks.
Found by Linux Verification Center (linuxtesting.org) with SVACE.