Compiling with Debug

826 views
Skip to first unread message

Thomas Johnson

unread,
Dec 26, 2009, 1:35:59 PM12/26/09
to Protocol Buffers
I've got a protobuf file that for some reason can't be loaded using
ParseFromIStream. The function just returns false, without printing
any error, and seems to deserialize only part of the message. How can
I compile a debug version of protobuf (i.e. -O0 -ggdb3) to step
through the code and find out what's going on?

Kenton Varda

unread,
Dec 27, 2009, 7:52:01 PM12/27/09
to Thomas Johnson, Protocol Buffers
./configure CXXFLAGS='-O0 -ggdb3'

Instead of stepping through the protobuf code, though, I'd recommend is that you add some code to your own project to read the bytes directly from the istream and then verify that they are the same bytes that were originally produced by the protobuf serializer.  You'll probably find that they are different in some way, which will point you towards the problem.


--

You received this message because you are subscribed to the Google Groups "Protocol Buffers" group.
To post to this group, send email to prot...@googlegroups.com.
To unsubscribe from this group, send email to protobuf+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/protobuf?hl=en.



Thomas Johnson

unread,
Dec 27, 2009, 8:31:30 PM12/27/09
to Kenton Varda, Protocol Buffers
Thanks for your help - I found that I was exceeding the recursion
limit in CodedInputStream. I was able to instantiate my own
CodedInputStream and increase the limit, but it would be nice if some
sort of error was printed when the limit is exceeded.

Kenton Varda

unread,
Dec 27, 2009, 10:07:51 PM12/27/09
to Thomas Johnson, Protocol Buffers
Huh, I thought we did print a message there, but I guess not.

That said, you're the first person I've ever heard of who hit that limit with (presumably) legitimate data.  Consider designing you protocol differently?  The limit exists for security reasons (to avoid stack overflows), so simply bumping it up isn't the best solution (though you can probably increase it significantly before running any real risks).

Thomas Johnson

unread,
Dec 27, 2009, 11:16:34 PM12/27/09
to Kenton Varda, Protocol Buffers
I understand why it's there, and it makes sense for apps in general. I
admit I'm using proto bufs for general serialization purposes within
my app rather than the over-the-wire communication tool it was
designed as. It just seems much easier to use than
boost::serialization or other alternatives. What I was serializing in
this case was a tree that had more than 64 levels, so yeah the data
was legitimate. Do you recommend a different library for general
purpose serialization?

Kenton Varda

unread,
Dec 28, 2009, 4:57:05 PM12/28/09
to Thomas Johnson, Protocol Buffers
I'm not sure what you mean by "general purpose serialization", but I'm pretty sure Protocol Buffers is what I'd use for it.

Very deep trees just call for a different layout when serialized, e.g. flatten the nodes to a list with each node containing the index of its parent node.
Reply all
Reply to author
Forward
0 new messages