mongoCXX: SIG: SEGFAULT while calling find_one()

From: javantamt <javantamt@xxxxxxxxx>
To: mongodb-user <mongodb-user@xxxxxxxxxxxxxxxx>
Date: Mon, 2 May 2016 14:54:58 -0700 (PDT)
Why ads?
Hey there!

I'm trying to implement some easy wrapper for mongoDB in withe the new cxx 
driver.
Calling in this assambly the funcion* find_one()* is throwing a segfault. I 
don't know why.
It looks like an obvious misstake...

Member function:
int CMongo::FindOne(std::string strJSONFind, std::string strJSONOrderBy, 
core::v1::optional<bsoncxx::v_noabi::document::value> &docReturn ){

  int iErr = 0;

  mongocxx::options::find MyFindOptions{};
  MyFindOptions.sort(bsoncxx::from_json(strJSONOrderBy).view());
  // core::v1::optional<bsoncxx::v_noabi::document::value> XXX;

  try{
  //docReturn = 
collJobs.find_one(bsoncxx::from_json(strJSONFind).view(),MyFindOptions);   
 // SEGFAULT
  // XXX = 
collJobs.find_one(bsoncxx::from_json(strJSONFind).view(),MyFindOptions); // 
segfault
   // auto i = 
collJobs.find_one(bsoncxx::from_json(strJSONFind).view(),MyFindOptions); // 
segfault
    auto i = collJobs.find_one(bsoncxx::from_json(strJSONFind).view(),
MyFindOptions);  // segfault

Class header:
class CMongo {
public:
  CMongo();

  int FindOne(
      std::string strJSONFind,
      std::string strJSONOrderBy,
      core::v1::optional<bsoncxx::v_noabi::document::value> &docReturn );
  virtual ~CMongo();

private:
  mongocxx::client conn;    // connection to database
  class mongocxx::v_noabi::collection collJobs;     
};



Class Constructor:
CMongo::CMongo() {
  // TODO Put this in every init functions withe a question of existence
  mongocxx::client conn(mongocxx::uri("Mongo credentiales" ));
  collJobs = conn["Database"]["collection"];
}

Function Call:
  CMongo MyMongo;
  core::v1::optional<bsoncxx::v_noabi::document::value> ReturnVal;
  MyMongo.FindOne("{\"started\":false}","{\"date\":1,\"priority\":1}",
ReturnVal);



-- 
You received this message because you are subscribed to the Google Groups "mongodb-user"
group.

For other MongoDB technical support options, see: https://docs.mongodb.org/manual/support/
--- 
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-user+unsubscribe@xxxxxxxxxxxxxxxx.
To post to this group, send email to mongodb-user@xxxxxxxxxxxxxxxx.
Visit this group at https://groups.google.com/group/mongodb-user.
To view this discussion on the web visit https://groups.google.com/d/msgid/mongodb-user/874bcd62-4f1d-47a4-9de2-27bb163ca3b3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Why ads?