This project has moved. For the latest updates, please go here.


SerializeValue/SerializeList stack overflow with active reference handling

description 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....?
Closed Jan 30, 2013 at 11:17 AM by JamesNK


JamesNK wrote Jan 22, 2013 at 10:39 AM

Could you comment or attached a simple example of a class that causes the error?

wrote Jan 25, 2013 at 9:45 AM

wrote Jan 30, 2013 at 11:17 AM

wrote Feb 22, 2013 at 2:47 AM

wrote May 16, 2013 at 1:36 PM