zhejiushizhuce / protobuf-net

Automatically exported from code.google.com/p/protobuf-net
0 stars 0 forks source link

Serialization mechanism using recursion, when serialize linked list (nested) structures it will generate Stack Overflow exception #162

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Please include an e-mail address if this might need a dialogue!
==============
siniy123@gmail.com
What steps will reproduce the problem?
1.
2.
3.

What is the expected output? What do you see instead?

What version of the product are you using? On what operating system?

Please provide any additional information below.
Serialization mechanism using recursion, when serialize linked list (nested) 
structures it will generate Stack Overflow exception

Original issue reported on code.google.com by siniy...@gmail.com on 10 Mar 2011 at 7:29

GoogleCodeExporter commented 9 years ago
I mean when serializing deeply nested structures.

Original comment by siniy...@gmail.com on 10 Mar 2011 at 8:27

GoogleCodeExporter commented 9 years ago
Is there a small sample fragment available? If you mean *structs* - that is 
very tricky; I might explicitly add code to the object-reference logic 
detecting structs and refusing to play, but they are virtually impossible to 
handle re recursion, as every time you glance at them they are a different 
(boxed)object.

Original comment by marc.gravell on 11 Mar 2011 at 6:22

GoogleCodeExporter commented 9 years ago
imagine this:
message Person
{
    required string name = 1;
    repeated Person child = 2;
}

so I created:
Person1
  Person2
    Person3
    ...
      PersonN

N is quite large number. Lets say 10k.
You implementation using recursion and hence consumes execution stack.
it runs out of stack (stack overflow exception) when serializing such nested 
message.

can you please delete my email from bug description, since I'm on gmail and you 
can contact me without it.
Thanks

Original comment by siniy...@gmail.com on 11 Mar 2011 at 4:14

GoogleCodeExporter commented 9 years ago
I think most serializers will struggle with an object model that deep; 
personally I don't think that is necessarily a great way to store the data. 
Changing the behaviour there would be very difficult.

(I don't seem able to delete the topmost question in a chain)

Original comment by marc.gravell on 11 Mar 2011 at 7:47

GoogleCodeExporter commented 9 years ago

Original comment by marc.gravell on 13 Jun 2011 at 8:34