Uploaded image for project: 'C++ Driver'
  1. C++ Driver
  2. CXX-1507

test.cpp from documentation page segfaults sometimes

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Incomplete
    • Icon: Minor - P4 Minor - P4
    • None
    • None
    • None
    • None
    • Fully Compatible

    Description

      All steps from online documentation:
      https://mongodb.github.io/mongo-cxx-driver/mongocxx-v3/installation/
      cxx driver installed from git with:
      git clone https://github.com/mongodb/mongo-cxx-driver.git \
      --branch releases/stable --depth 1

      created test.cpp with contents:

      #include <iostream>
       
      #include <bsoncxx/builder/stream/document.hpp>
      #include <bsoncxx/json.hpp>
       
      #include <mongocxx/client.hpp>
      #include <mongocxx/instance.hpp>
       
      int main(int, char**) {
          mongocxx::instance inst{};
          mongocxx::client conn{mongocxx::uri{}};
       
          bsoncxx::builder::stream::document document{};
       
          auto collection = conn["testdb"]["testcollection"];
          document << "hello" << "world";
       
          collection.insert_one(document.view());
          auto cursor = collection.find({});
       
          for (auto&& doc : cursor) {
              std::cout << bsoncxx::to_json(doc) << std::endl;
          }
      }
      

      compiled with:

      c++ --std=c++11 test.cpp -o test \
          -I/usr/local/include/mongocxx/v_noabi \
          -I/usr/local/include/bsoncxx/v_noabi \
          -L/usr/local/lib -lmongocxx -lbsoncxx
      

      Sometimes crashes.
      *Backtrace:

      #0  0x00007ffff6f02266 in bson_destroy () from /usr/local/lib/libbson-1.0.so.0
      #1  0x00007ffff71739e5 in _mongoc_write_command_destroy () from /usr/local/lib/libmongoc-1.0.so.0
      #2  0x00007ffff713d7a7 in mongoc_bulk_operation_destroy () from /usr/local/lib/libmongoc-1.0.so.0
      #3  0x00007ffff7b3da71 in mongocxx::v_noabi::bulk_write::~bulk_write() () from /usr/local/lib/libmongocxx.so._noabi
      #4  0x00007ffff7b43ba1 in mongocxx::v_noabi::collection::insert_one(bsoncxx::v_noabi::view_or_value<bsoncxx::v_noabi::document::view, bsoncxx::v_noabi::document::value>, mongocxx::v_noabi::options::insert const&) () from /usr/local/lib/libmongocxx.so._noabi
      #5  0x0000555555555b7e in main ()
      *(gdb)
      

      Attachments

        Activity

          People

            andrew.morrow@mongodb.com Andrew Morrow (Inactive)
            mikesi Miha Nedok
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: