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

Test failure: System.Text.Json.Serialization.Tests.JsonElementTests.DeepEquals_TooDeepJsonDocument_ThrowsInsufficientExecutionStackException #105532

Closed
v-wenyuxu opened this issue Jul 26, 2024 · 8 comments · Fixed by #105836
Labels
arch-x64 area-crossgen2-coreclr in-pr There is an active PR which will close this issue when it is merged os-linux Linux OS (any supported distro)
Milestone

Comments

@v-wenyuxu
Copy link

Failed in: runtime-coreclr crossgen2 20240724.1

Failed tests:

net9.0-linux-Release-x64-TestReadyToRun_Release-Ubuntu.2204.Amd64.Open
    - System.Text.Json.Serialization.Tests.JsonElementTests.DeepEquals_TooDeepJsonDocument_ThrowsInsufficientExecutionStackException
net9.0-linux-Release-x64-TestReadyToRun_Release-(Centos.8.Amd64.Open)[email protected]/dotnet-buildtools/prereqs:centos-stream8-helix
    - System.Text.Json.Serialization.Tests.JsonElementTests.DeepEquals_TooDeepJsonDocument_ThrowsInsufficientExecutionStackException
net9.0-linux-Release-x64-TestReadyToRun_Release-(Debian.11.Amd64.Open)[email protected]/dotnet-buildtools/prereqs:debian-11-helix-amd64
    - System.Text.Json.Serialization.Tests.JsonElementTests.DeepEquals_TooDeepJsonDocument_ThrowsInsufficientExecutionStackException

Error message:

 Assert.Throws() Failure: No exception was thrown
Expected: typeof(System.InsufficientExecutionStackException)

Stack trace:

   at System.Text.Json.Serialization.Tests.JsonElementTests.DeepEquals_TooDeepJsonDocument_ThrowsInsufficientExecutionStackException() in /_/src/libraries/System.Text.Json/tests/System.Text.Json.Tests/Serialization/JsonElementTests.cs:line 237

   at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
   at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)
@v-wenyuxu v-wenyuxu added os-linux Linux OS (any supported distro) arch-x64 area-crossgen2-coreclr labels Jul 26, 2024
@dotnet-policy-service dotnet-policy-service bot added the untriaged New issue has not been triaged by the area owner label Jul 26, 2024
@lambdageek
Copy link
Member

@stephentoub interesting. the test you updated doesn't throw when crossgen is enabled. I'm not sure if it's expected that crossgen'd code uses less stack. Is there a way to make that test case deeper?

@stephentoub
Copy link
Member

stephentoub commented Jul 30, 2024

We can change this 10_000:

using JsonDocument jDoc = CreateDeepJsonDocument(10_000);

to something arbitrarily large. The value should be limited only by available memory. The goal here is effectively to stack overflow, so, yeah 😄

@ivdiazsa
Copy link
Member

ivdiazsa commented Aug 1, 2024

Just for clarification, is this a test failure rather than a product failure? And is it being worked on already? @lambdageek @stephentoub

@lambdageek
Copy link
Member

@ivdiazsa yea my suspicion is that the test needs to create more recursion. the way the test works is it creates some data structure and then starts a new thread with a small amount of stack space and then does some recursive calls exploring the data structure. The expectation is that it will throw an InsufficientExecutionStackException. With the JIT the current test case is deep enough. but with ReadyToRun, apparently not.

I don't think anyone is working on it.

@stephentoub
Copy link
Member

I'll submit a PR to bump up the value.

@dotnet-policy-service dotnet-policy-service bot added the in-pr There is an active PR which will close this issue when it is merged label Aug 1, 2024
@EgorBo
Copy link
Member

EgorBo commented Aug 1, 2024

then does some recursive calls exploring the data structure.

Just a side note that such assumptions may not be valid when JIT applies tail-call optimizations. e.g.:

void foo()
{
    foo();
}

does this code throw SO? the answer is: depends on optimization level

@stephentoub
Copy link
Member

then does some recursive calls exploring the data structure.

Just a side note that such assumptions may not be valid when JIT applies tail-call optimizations. e.g.:

void foo()
{
foo();
}
does this code throw SO? the answer is: depends on optimization level

I wouldn't expect tail call optimizations to kick in here, though:

if (!DeepEquals(prop1.Value, prop2.Value))
{
return false;
}
count--;

Is my mental model off?

@EgorBo
Copy link
Member

EgorBo commented Aug 1, 2024

I wouldn't expect tail call optimizations to kick in here, though:

Agree

@ivdiazsa ivdiazsa removed the untriaged New issue has not been triaged by the area owner label Aug 5, 2024
@ivdiazsa ivdiazsa added this to the 9.0.0 milestone Aug 5, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Sep 8, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
arch-x64 area-crossgen2-coreclr in-pr There is an active PR which will close this issue when it is merged os-linux Linux OS (any supported distro)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants