Folks,

I have the below code to test ReportModified API functionality. I am having 
issue in using this and facing a SIGSEGV crash.

My code is as below.


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

    cfgMsg1->set_msgid(100);
    cfgMsg1->set_cfgname("obj1");

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

        /* Fill some repeated fields */
    }
    serverMsg1.set_allocated_cfgmsg(cfgMsg1);

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

    cfgMsg2->set_msgid(100);
    cfgMsg2->set_cfgname("obj1");

    for (int j = 1; j < 3; j++) {
   
         /* Fill some repeated fields */

    }
    serverMsg2.set_allocated_cfgmsg(cfgMsg2);
    MessageDifferencer msgDiff;
    msgDiff.set_report_matches(true);
    msgDiff.set_report_moves(true); 
   
    msgDiff.set_scope(MessageDifferencer::FULL);
    std::string diffReport;
    std::string output;
    StringOutputStream output_stream(&output);
    MessageDifferencer::StreamReporter reporter(&output_stream);
    reporter.set_report_modified_aggregates(false);
    msgDiff.ReportDifferencesToString(&diffReport);
    msgDiff.ReportDifferencesTo(&reporter);

    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 ()
(gdb)

Any clue on how to move forward on this ?

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to protobuf+unsubscr...@googlegroups.com.
To post to this group, send email to protobuf@googlegroups.com.
Visit this group at https://groups.google.com/group/protobuf.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/protobuf/74f4e5d6-f242-4e49-89fb-e87439f0a333%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to