-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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 OverflowException in JsonSerializer.Serialize #1308
Conversation
src/libraries/System.Text.Json/src/System/Text/Json/Serialization/PooledByteBufferWriter.cs
Show resolved
Hide resolved
Commenter does not have sufficient privileges for PR 1308 in repo dotnet/runtime |
/azp run |
You have several pipelines (over 10) configured to build pull requests in this repository. Specify which pipelines you would like to run by using /azp run [pipelines] command. You can specify multiple pipelines using a comma separated list. |
@ahsonkhan, @steveharter, can you take a look as well? Thanks. |
src/libraries/System.Text.Json/tests/Serialization/WriteValueTests.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Text.Json/tests/Serialization/WriteValueTests.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Text.Json/tests/Serialization/WriteValueTests.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Text.Json/src/System/Text/Json/Serialization/PooledByteBufferWriter.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Text.Json/src/System/Text/Json/Serialization/PooledByteBufferWriter.cs
Show resolved
Hide resolved
src/libraries/System.Text.Json/tests/Serialization/WriteValueTests.cs
Outdated
Show resolved
Hide resolved
We should consider making a similar fix to the public runtime/src/libraries/Common/src/System/Buffers/ArrayBufferWriter.cs Lines 168 to 180 in fd7a5e8
|
51277d7
to
517e054
Compare
@felipepessoto, sorry for the delay. This looks good and ready to go, but there's a conflict in the tests now... can you rebase to address it? |
Yes sure. But I still have some pending things to do. I still didn't stop to check how can I restrict the test to 64bits, and I couldn't run the coverage test yet, last time it took hours and didn't finish |
e.g.
|
src/libraries/System.Text.Json/src/System/Text/Json/Serialization/PooledByteBufferWriter.cs
Outdated
Show resolved
Hide resolved
You are probably building using a debug coreclr which causes tests to take a long time to run. If you build coreclr for release and then build the libraries using the release coreclr, the tests should run faster. I was able to run the coverage after merging master into your branch (by changing your test to be part of inner loop, removed outerloop from attribute): See #839 (comment) cc @safern, @ViktorHofer - do we need to increase the visibility of this issue so fewer folks hit against running tests with debug coreclr, by default? Looks like all the new branches introduced in this PR are covered by the test :) The path that is likely not covered (and this sequence of code flow won't show up in test coverage): If you do run all outerloop tests, it will take a lot longer (~10 minutes for me, but shouldn't take hours):
|
At first I tried to create five internal references to CustomClassToExceedMaxBufferSize and create 25 levels deep instances, but the tests ran forever. So I changed it to have several big string properties, which lead to the System.OverflowException using 3 level deep instance.
…s to use growBy = sizeHint If it still overflow, we set the newSize to int.MaxValue, which will throw an OutOfMemoryException when calling ArrayPool.Rent.
OuterLoop Make the test simpler
Run test on 64 bits only
517e054
to
728de73
Compare
Thx, done |
src/libraries/System.Text.Json/tests/Serialization/WriteValueTests.cs
Outdated
Show resolved
Hide resolved
Separate OuterLoop attribute, to be consistent with the other tests in this solution.
@felipepessoto - are you up for making a similar fix to runtime/src/libraries/Common/src/System/Buffers/ArrayBufferWriter.cs Lines 158 to 183 in 4f71081
|
Absolutely |
Fix #609