Ok - found it. The problem was not on the serialization but on the
message creation/parsing. The buffer the C++ code was parsing the
protocol buffer message from was not properly initialized causing the
ByteSize() function to return an incorrect value based on the junk
padded past the typical sentinel.

I did a call to memset prior and all is good.

Two additional thoughts:

1) I am surprised the C++ parsing succeeded?

2) Why was the serialization reproducing the bad input? I would think
the process of Marshalling/Unmarshalling would of cleaned it up.

On Dec 17, 10:48 am, Ryan <ryanroll...@gmail.com> wrote:
> I will try. A good debugging step for myself if not anything else.
> This system is of course distributed so it may be difficult to isolate
> it down into something I can send you easily (also lots of
> dependencies). I have been trying to identify the messages that are
> causing this but it appears to be happening independent of the message
> contents.
>
> In a particular sequence of messages the same messages always get the
> erroneous bytes appended. However, if I take one of those messages and
> send it independently - works fine.
>
> Weird...
>
> Thanks for the dialog.
>
> On Dec 17, 9:36 am, Kenton Varda <ken...@google.com> wrote:
>
> > If you write a program demonstrating the problem and send it to me, I can
> > debug it.
>
> > On Wed, Dec 17, 2008 at 11:10 AM, Ryan <ryanroll...@gmail.com> wrote:
>
> > >    char mess[MAX_MESSLEN] ;
> > >   .
> > >    //Load some properties for the group com call
> > >   .
> > >   .
> > >    bplMessage.SerializeToArray(mess,bplMessage.ByteSize());
>
> > > //what I am using to detect trailing bytes
> > >    for(int i =0; i< bplMessage.ByteSize();i++) {
> > >        std::cout << (int) mess[i] << std::endl;
> > >     }
>
> > > On Dec 17, 8:32 am, Kenton Varda <ken...@google.com> wrote:
> > > > Hi Ryan,
> > > > What does your code look like that calls SerializeToArray()?  It should
> > > be
> > > > something like:
>
> > > >   int size = message.ByteSize();
> > > >   char* array = new char[size];
> > > >   message.SerializeToArray(array, size);
>
> > > > On Tue, Dec 16, 2008 at 8:13 PM, Ryan <ryanroll...@gmail.com> wrote:
>
> > > > > I have been working with a Group Communication System and Protocol
> > > > > Buffers.
>
> > > > > I have an issue where the C++ SerializeToArray call on one of my
> > > > > messages is occasionally appending Bytes {1,0,0,0,0,0,0,0,0} to the
> > > > > end of the returned character array?
>
> > > > > Any ideas on what might be causing this? I can Marshall/Unmarshall
> > > > > fine using the java api but the C++ call above has the odd quirk
> > > > > mentioned.
>
> > > > > The Java parsingFrom fails on the C++ generated messages that have the
> > > > > above bytes appended.
>
> > > > > Any suggestions much appreciated.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To post to this group, send email to protobuf@googlegroups.com
To unsubscribe from this group, send email to 
protobuf+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/protobuf?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to