segment fault with vector

XMLWordPrintableJSON

    • Type: Task
    • Resolution: Done
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • Environment:
      centos 5.5
      boost1.55
      gcc4.8.2
      mongo-cxx-driver(legacy)
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      Hi
      First,I introduce the installtion of mongo-cxx.My centos has gcc4.8.2 and gcc4.4.6, but I install the boost1.55 and mongo-cxx with gcc4.8.2. And it's fine.
      I have a function to get query results and push them into a vector(vec). But when I get the data from the vec, segment fault occurs. code is :

              cursor = conn->query(dbco , obj);
      	vector<BSONObj> vObj;
      	while(cursor->more()){
      		vObj.push_back(cursor->next());
      	}
              BSONObj temp = vObj[0];// vObj.size()>0
              cout << temp.objsize()<<endl;
      

      gdb debug info is :

      (gdb) bt
      #0  0x00007ffff6432e36 in ?? ()
      #1  0x000000000040b460 in mongo::ConstDataView const& mongo::ConstDataView::readNative<int>(int*, unsigned long) const ()
      #2  0x000000000040a491 in int mongo::ConstDataView::readNative<int>(unsigned long) const ()
      #3  0x0000000000409627 in int mongo::ConstDataView::readLE<int>(unsigned long) const ()
      #4  0x0000000000408d3d in mongo::BSONObj::objsize() const ()
      

      anyone know this?

      the some code is fine with my mac.

            Assignee:
            Unassigned
            Reporter:
            Better Wang
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: