Access violation exception in C++ driver

236 views
Skip to first unread message

AlexB

unread,
Nov 10, 2016, 5:09:36 PM11/10/16
to mongodb-user
Hello,

Just started working with MongoDB.
I have compiled C++ driver using cxx-driver-r3.0.2, mongo-c-driver-1.4.2 and boost_1_62_0.
My environment: Windows 10 Pro, Visual Studio 2015 Pro. The driver is compiled for the x64 platform w/o any issues.
But I can't even connect to the database, it crashes on the second statement here (in bold):

mongocxx::uri uri("mongodb://myserver:27017");
mongocxx::client client(uri);

Here is the call stack:
  libmongoc-1.0.dll!mongoc_counter_clients_active_add(__int64 val) Line 42 C
  libmongoc-1.0.dll!mongoc_counter_clients_active_inc() Line 42 C
  libmongoc-1.0.dll!_mongoc_client_new_from_uri(const _mongoc_uri_t * uri, _mongoc_topology_t * topology) Line 776 C
  libmongoc-1.0.dll!mongoc_client_new_from_uri(const _mongoc_uri_t * uri) Line 700 C
  mongocxx.dll!00007ffda5e10aa4() Unknown
  MyMongo.exe!main(int argc, char * * argv) Line 32 C++
  [External Code] 

The exact line of code where the exception is thrown (mongoc-counters.defs):
COUNTER(clients_active,         "Clients",      "Active",              "The number of active clients.")

Any idea how to resolve this?

Thanks,
Alex

Andrew Morrow

unread,
Nov 10, 2016, 5:13:31 PM11/10/16
to mongod...@googlegroups.com

Hi -

Did you create a mongocxx::instance object? You must do so before using any of the other types in the library, and you must keep the instance object alive until you are done using the driver. See 


For one example of how to do this.

Thanks,
Andrew


--
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.com/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@googlegroups.com.
To post to this group, send email to mongod...@googlegroups.com.
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/a9258125-3f7a-43a1-a3a8-b19ae1393bda%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

AlexB

unread,
Nov 10, 2016, 5:40:41 PM11/10/16
to mongodb-user
That was it! Thank you Andrew.
Reply all
Reply to author
Forward
0 new messages