There is an unsaved comment in progress. You will lose your changes if you continue. Are you sure you want to reopen the work item?
SerializeValue/SerializeList stack overflow with active reference handling
Json.net 4.5.11 has a major issue where you can get a StackOverflowException even if PreserveReferencesHandling is nset to PreserveReferencesHandling.All and ReferenceLoopHandling is set to ReferenceLoopHandling.Error.
The callstack shows SerializeValue, SerializeList, SerializeValue, SerializeList, SerializeValue, SerializeList and so on.
When I take a look at the source code, I see that there is a call from SerializeValue to SerializeList when the contract type is a one-dimensional array and SerializeList calls SerializeValue for each item in the list. This looks correct so far, but when you
follow these calls you can see that there is no checking for known references.
I am a bit unsure why, but I think that the problem is that for JsonContainerContract instances, the IsReference property is never set automatically, but only from attributes. So, when contracts are auto-generated from reflection, IsReference is always false.
But it should be true for classes and arrays....?