I am having problems where my message fails to serialize. A fatal exception 
is thrown for the ' ResponseMessage.SerializeToCodedStream(coded_output);'. 
ResponseMessage contains all the required fields, and is 104 bytes without 
the varint....

I am compiling this for 64 bit windows, using the 32bit protoc.exe.

// Send the response message

         // Get the byte size of the response message
         uint32_t response_message_size = ResponseMessage.ByteSize();

         // Add the varint size to the total message size
         uint32_t response_message_total_size = response_message_size 
+ google::protobuf::io::CodedOutputStream::VarintSize32(response_message_size);

         boost::asio::streambuf buffer_stream;
         std::ostream output_stream(&buffer_stream);

         google::protobuf::io::ZeroCopyOutputStream* raw_output =
            new google::protobuf::io::OstreamOutputStream(&output_stream);

         google::protobuf::io::CodedOutputStream* coded_output =
            new google::protobuf::io::CodedOutputStream(raw_output);


            delete coded_output;
            delete raw_output;

            bytes_sent = m_Socket.send(buffer_stream.data());
         catch( google::protobuf::FatalException )

            delete raw_output;
            delete coded_output;
            bytes_sent = 0;

On Tuesday, February 7, 2012 7:45:29 AM UTC-8, Evan Jones wrote:
> On Feb 6, 2012, at 21:54 , Robby Zinchak wrote:
> > It turned out to be an uninitialized boolean.  Properly setting the 
> value in question seems to allow things to proceed normally.
> Ah! Interesting. So one of your .set_* properties is a boolean, and one of 
> them was uninitialized? That would do it. This was discussed previously and 
> dismissed as a "wont fix" problem, because it is hard/impossible to make 
> portable code that will test for this:
> http://code.google.com/p/protobuf/issues/detail?id=234
> Although its somewhat confusing since WireFormatLite::WriteBoolNoTag 
> contains code to try to avoid this problem, which GCC helpfully optimizes 
> away.
> I am not able to get the exact crash as the one you reported, but I can 
> get it to crash in MessageLite::SerializeWithCachedSizesToArray by creating 
> a boolean with a value of 0x80 (serializing to two bytes instead of one, 
> causing it to create a message larger than it expects). I can't figure out 
> how it could crash at the point you report the crash, but that doesn't 
> really matter.
> Glad you got it working,
> Evan
> --
> http://evanjones.ca/

You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To view this discussion on the web visit 
To post to this group, send email to protobuf@googlegroups.com.
To unsubscribe from this group, send email to 
For more options, visit this group at 

Reply via email to