I need to compute the difference between two protobuf objects of same type. i.e difference between attribute values of each object, So I am planning to use ReportModified() API provided by Google Protocol Buffers.

I have the below code to test ReportModified API functionality. I went through the documentation present at But couldn't really figure out the reason for this crash.

I am having issue in using this and facing a SIGSEGV crash.

I wrote a small function as shown below to test this functionality.

bool compare_gpb()
    ConfigMsg *cfgMsg1 = new ConfigMsg();
    CfgServerMsg serverMsg1;


    for (int j = 1; j < 3; j++) {

        /* Fill some repeated fields */

    ConfigMsg *cfgMsg2 = new ConfigMsg();
    CfgServerMsg serverMsg2;


    for (int j = 1; j < 3; j++) {

         /* Fill some repeated fields */

    MessageDifferencer msgDiff;

    std::string diffReport;
    std::string output;
    StringOutputStream output_stream(&output);
    MessageDifferencer::StreamReporter reporter(&output_stream);

    std::cout << "Result is:" << msgDiff.Compare(serverMsg1, serverMsg2) << std::endl;

    std::cout << "The Differences are:" << output << std::endl;

    std::vector<MessageDifferencer::SpecificField> path;

    const CfgServerMsg &message1(serverMsg1);
    const CfgServerMsg &message2(serverMsg2);

    reporter.ReportModified(message1, message2, path);
    std::cout << "The ReportModified size " << path.size() << std::endl;

I see that ReportModified crashes with the below call stack.

(gdb) bt
#0  google::protobuf::util::MessageDifferencer::StreamReporter::PrintValue (
    this=0x7ffdea175c20, message=warning: RTTI symbol not found for class 'cfg::CfgServerMsg'
..., field_path=std::vector of length 0, capacity 0, 
    left_side=true) at google/protobuf/util/message_differencer.cc:1787
#1  0x00000000004fd0df in google::protobuf::util::MessageDifferencer::StreamReporter::ReportModified (this=0x7ffdea175c20, message1=warning: RTTI symbol not found for class 'cfg::CfgServerMsg'
..., message2=warning: RTTI symbol not found for class 'cfg::CfgServerMsg'
    field_path=std::vector of length 0, capacity 0)
    at google/protobuf/util/message_differencer.cc:1900
#2  0x00000000004b13b4 in compare_gpb() ()
#3  0x00000000004b171f in main ()

It should show the fields/attributes that are modified in message 2.

Any help on how to move forward, next steps or some example code to figure out more ? In fact details o any Report*** (ReportAdded, ReportMove, ReportDeleted) API should be helpful.

0 Answers