Re: Can't serialize more than 28 fields in a message when built with VS 2010 64 bit compile setup

107 views
Skip to first unread message

Dave

unread,
Aug 27, 2012, 3:51:48 PM8/27/12
to prot...@googlegroups.com
This is caused by a bug in protoc.exe not generating code correctly.  Oddly enough if I use the debug build of protoc.exe it does generate the code correctly.  So I'm using that until someone can figure out what's wrong with protoc.exe.  FYI, this is a duplicate of another post I made and can be deleted by someone that knows how.

On Friday, August 24, 2012 3:52:48 PM UTC-5, Dave wrote:
As you can see the 28th field has a bit mask setup in the generated code:
// optional int32 StateSequence = 28;
inline bool Order::has_statesequence() const {
  return (_has_bits_[0] & 0x88000000u) != 0;
}
inline void Order::set_has_statesequence() {
  _has_bits_[0] |= 0x88000000u;
}
inline void Order::clear_has_statesequence() {
  _has_bits_[0] &= ~0x88000000u;
}

The 29th field does not:
// optional .OXObjects.OrderStates OrderState = 29;
inline bool Order::has_orderstate() const {
  return (_has_bits_[0] & 0x00000000u) != 0;
}
inline void Order::set_has_orderstate() {
  _has_bits_[0] |= 0x00000000u;
}
inline void Order::clear_has_orderstate() {
  _has_bits_[0] &= ~0x00000000u;
}

Anyone have a fix for this in the protoc.exe code generator?

Dave

unread,
Nov 8, 2012, 2:53:46 PM11/8/12
to prot...@googlegroups.com
The code snippet I posted above is the result of using the protc.exe that was built 64-bit release mode and code generating a message with more than 28 fields.  The snippet is the code that was generated by that protc.exe.  Like I explained you are ok as long as you don't use the 64 bit build of protc.exe.   Which we do not.  Now there are many other little things you need to do if you want to use a full 64 bit version of the code.  There are alot of warning you need to deal with, plus if your using VS2012 you've got to fix all the c++11 incompatibilities.   So yes we still experience the problem but we work around it.  This whole project really needs some time dedicated to 64 bit build support and the new c++11 standard along with VS2012.
 

 Friday, November 2, 2012 4:40:36 PM UTC-5, Robert Graham wrote:
Are you still experiencing this problem? I am currently build 32/64 bit files. I am using the 64 bit protoc when building under a 64 bit host machine. Are you only experiencing this using the 64-bit protoc? Or when linking against the 64-bit google protocol libraries?

Robert Graham

unread,
Nov 30, 2012, 7:45:05 PM11/30/12
to prot...@googlegroups.com
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);

         try
         {
            coded_output->WriteVarint32(response_message_size);
            ResponseMessage.SerializeToCodedStream(coded_output);

            delete coded_output;
            delete raw_output;

            bytes_sent = m_Socket.send(buffer_stream.data());
         }
         catch( google::protobuf::FatalException )
         {
            assert(false);

            delete raw_output;
            delete coded_output;
            bytes_sent = 0;
         }
Reply all
Reply to author
Forward
0 new messages