Open madelson opened 3 years ago
It works fine on my desktop, but fails on CI build. I'm guessing something about .NET Core in low resource environments decreases the available stack size, and makes a stack overflow easier.
We met the same issue, is there any thing we can do to avoid this exception?
Thanks for maintaining this great library! I'm running into an interesting issue porting my Json.NET code from .NET Framework to .NET Core.
Steps to reproduce
Expected behavior
Setting a max depth setting that is much less than the max stack should prevent stackoverflow when deserializing. Behavior should be comparable between .NET Framework and .NET Core.
Actual behavior
.NET Framework behaves as expected but when running against .NET Core (target framework netcoreapp3.1) stack overflows very quickly.
When examining in the debugger, it seems like the stack overflow occurs AFTER the max depth trigger is hit and not during the recursion down to that depth (perhaps when constructing the exception?).
This is concerning for us because we use MaxDepth to protect from application crashes due to stack overflow. While 150 may seem like plenty of depth, I've seen it fail with even lower depth values in more complex scenarios with things like custom JsonConverters adding to the stack (not to mention whatever initial depth the serialization occurs at).