Discussion:
[mongodb-user] Access violation exception in C++ driver
AlexB
2016-11-10 22:04:38 UTC
Permalink
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
--
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+***@googlegroups.com.
To post to this group, send email to mongodb-***@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.
Andrew Morrow
2016-11-10 22:13:18 UTC
Permalink
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

https://github.com/mongodb/mongo-cxx-driver/blob/8d083652095230cab6071ddf62a1103eb95f6530/examples/mongocxx/instance_management.cpp

For one example of how to do this.

Thanks,
Andrew
Post by AlexB
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
*mongocxx::uri uri("mongodb://myserver:27017");mongocxx::client
client(uri);*
* 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
*COUNTER(clients_active, "Clients", "Active",
"The number of active clients.")*
Any idea how to resolve this?
Thanks,
Alex
--
You received this message because you are subscribed to the Google Groups "mongodb-user"
group.
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
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
<https://groups.google.com/d/msgid/mongodb-user/a9258125-3f7a-43a1-a3a8-b19ae1393bda%40googlegroups.com?utm_medium=email&utm_source=footer>
.
For more options, visit https://groups.google.com/d/optout.
--
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+***@googlegroups.com.
To post to this group, send email to mongodb-***@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/CAHX05qE4Bf9f5ko4Aox_H86gBGTUQrT6-8O5YYzWsOJSHM39bw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
AlexB
2016-11-10 22:40:41 UTC
Permalink
That was it! Thank you 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+***@googlegroups.com.
To post to this group, send email to mongodb-***@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/d812d182-8fce-441e-bada-2ca074386260%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Continue reading on narkive:
Loading...