Discussion:
mongo-cxx-driver or my program inconsistency.
(too old to reply)
Rodrigo Broggi
2018-11-06 21:14:37 UTC
Permalink
Hi all,

I've been playing around with mongo-cxx-driver since I would like to become
a contributor. After following the driver tutorial I've setup a toy program
to interact with my local mongod instance. The weird part is that I have
inconsistent results each time I run the program: the program is very
simple and it should insert some data using separate threads and read all
that data once the insertion is complete. The issue is that sometimes the
program works correctly and the result is as expected:


{ "_id" : { "$oid" : "5be200e156acbb414f462a62" }, "id" : 1, "name" : "a" }
{ "_id" : { "$oid" : "5be200e156acbb414f462a63" }, "id" : 2, "name" : "b" }
{ "_id" : { "$oid" : "5be200e156acbb414f462a64" }, "id" : 3, "name" : "c" }
{ "_id" : { "$oid" : "5be200e156acbb414f462a65" }, "id" : 4, "name" : "d" }
{ "_id" : { "$oid" : "5be200e156acbb414f462a66" }, "id" : 5, "name" : "e" }
{ "_id" : { "$oid" : "5be200e156acbb414f462a67" }, "id" : 6, "name" : "f" }


other times I receive an error from the execution:



Process finished with exit code 11


still other times the data fetched is incomplete:

{ "_id" : { "$oid" : "5be2038156acbb43c05f5ab2" }, "id" : 2, "name" : "b" }
{ "_id" : { "$oid" : "5be2038156acbb43c05f5ab4" }, "id" : 3, "name" : "c" }
{ "_id" : { "$oid" : "5be2038156acbb43c05f5ab6" }, "id" : 5, "name" : "e" }
{ "_id" : { "$oid" : "5be2038156acbb43c05f5ab7" }, "id" : 6, "name" : "f" }


I can't spot the source of the error in my program, there is probably an
error my c++ programming (my c++ is a bit rusty rsrs). In attachment you
can find the program (it is a very simple main function).

Thank you all,
Br,

Rodrigo
--
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/db218e18-64c7-4e72-9803-ec25462b70e3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Bob Cochran
2018-11-06 21:25:24 UTC
Permalink
Hello Rodrigo,

What versions of the driver are you using?

How did you compile and link — what is the exact invocation you used?

Thanks

Bob
Post by Rodrigo Broggi
Hi all,
{ "_id" : { "$oid" : "5be200e156acbb414f462a62" }, "id" : 1, "name" : "a" }
{ "_id" : { "$oid" : "5be200e156acbb414f462a63" }, "id" : 2, "name" : "b" }
{ "_id" : { "$oid" : "5be200e156acbb414f462a64" }, "id" : 3, "name" : "c" }
{ "_id" : { "$oid" : "5be200e156acbb414f462a65" }, "id" : 4, "name" : "d" }
{ "_id" : { "$oid" : "5be200e156acbb414f462a66" }, "id" : 5, "name" : "e" }
{ "_id" : { "$oid" : "5be200e156acbb414f462a67" }, "id" : 6, "name" : "f" }
Process finished with exit code 11
{ "_id" : { "$oid" : "5be2038156acbb43c05f5ab2" }, "id" : 2, "name" : "b" }
{ "_id" : { "$oid" : "5be2038156acbb43c05f5ab4" }, "id" : 3, "name" : "c" }
{ "_id" : { "$oid" : "5be2038156acbb43c05f5ab6" }, "id" : 5, "name" : "e" }
{ "_id" : { "$oid" : "5be2038156acbb43c05f5ab7" }, "id" : 6, "name" : "f" }
I can't spot the source of the error in my program, there is probably an error my c++ programming (my c++ is a bit rusty rsrs). In attachment you can find the program (it is a very simple main function).
Thank you all,
Br,
Rodrigo
--
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.
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/db218e18-64c7-4e72-9803-ec25462b70e3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
<mongo_test.cpp>
--
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/94BCCD74-A643-499B-A79E-C94C47577EA5%40gmail.com.
For more options, visit https://groups.google.com/d/optout.
Robert Cochran
2018-11-07 03:22:45 UTC
Permalink
Hi Rodrigo,

I downloaded your code, and reviewed it quickly. I am a rank, unwashed
beginner with C++ programs, and I can just barely code a "Hello World" in
C.

I looked at the MongoDB C++ quick start, and then looked at your code.

I do not understand why you are using connection pools. The tutorial
suggests those are only needed for replica sets. I wonder if the signal 11
has to do with use of connection pools and related memory errors.

Your code seems to be trying to create 6 databases and each database will
have 6 collections.

The compiler invocation that I used was:

c++ --std=c++11 mongo_test.cpp -o mongo_test $(shell pkg-config --cflags --libs
libmongocxx) -lpthread -Wl,-rpath,/home/vagrant/local/lib


...and this is for version 3.4.0 of the driver, using mongo-c-driver
version 1.13.0. It certainly compiled fine.

Thanks

Bob
Post by Rodrigo Broggi
Hi all,
I've been playing around with mongo-cxx-driver since I would like to
become a contributor. After following the driver tutorial I've setup a toy
program to interact with my local mongod instance. The weird part is that I
have inconsistent results each time I run the program: the program is very
simple and it should insert some data using separate threads and read all
that data once the insertion is complete. The issue is that sometimes the
{ "_id" : { "$oid" : "5be200e156acbb414f462a62" }, "id" : 1, "name" : "a" }
{ "_id" : { "$oid" : "5be200e156acbb414f462a63" }, "id" : 2, "name" : "b" }
{ "_id" : { "$oid" : "5be200e156acbb414f462a64" }, "id" : 3, "name" : "c" }
{ "_id" : { "$oid" : "5be200e156acbb414f462a65" }, "id" : 4, "name" : "d" }
{ "_id" : { "$oid" : "5be200e156acbb414f462a66" }, "id" : 5, "name" : "e" }
{ "_id" : { "$oid" : "5be200e156acbb414f462a67" }, "id" : 6, "name" : "f" }
Process finished with exit code 11
{ "_id" : { "$oid" : "5be2038156acbb43c05f5ab2" }, "id" : 2, "name" : "b" }
{ "_id" : { "$oid" : "5be2038156acbb43c05f5ab4" }, "id" : 3, "name" : "c" }
{ "_id" : { "$oid" : "5be2038156acbb43c05f5ab6" }, "id" : 5, "name" : "e" }
{ "_id" : { "$oid" : "5be2038156acbb43c05f5ab7" }, "id" : 6, "name" : "f" }
I can't spot the source of the error in my program, there is probably an
error my c++ programming (my c++ is a bit rusty rsrs). In attachment you
can find the program (it is a very simple main function).
Thank you all,
Br,
Rodrigo
--
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/85ad38c6-13de-49f6-b13a-b534c91896c0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Rodrigo Broggi
2018-11-07 12:34:34 UTC
Permalink
Hi Bob,

First of all thank you for taking the time and looking into it.

I'm using the latest stable version of c++ driver and version 1.13.0 of c
driver.

Regarding the pool - I've followed the instructions on
mongo-cxx-thread-safety <http://mongocxx.org/mongocxx-v3/thread-safety/> which
specifically states that the best practice for working on multithreading
environment so to delegate to the driver framework the synchronisation
responsibilities. I could have miss-interpreted the section.

The code actually inserts 6 different documents (using separate threads)
into different databases/collections:

doc 1 -> into db "dbOne" collection "collectionOne"
doc 2 -> into db "dbTwo" collection "collectionTwo"
doc 3 -> into db "dbOne" collection "collectionThree"
doc 4 -> into db "dbTwo" collection "collectionOne"
doc 1 -> into db "dbOne" collection "collectionTwo"
doc 1 -> into db "dbTwo" collection "collectionThree"

Finally the main thread fetches the same data. I've enhanced the code a
little to log some stuff to stdout.

Thank you again and best regards,
Rodrigo
Post by Rodrigo Broggi
Hi all,
I've been playing around with mongo-cxx-driver since I would like to
become a contributor. After following the driver tutorial I've setup a toy
program to interact with my local mongod instance. The weird part is that I
have inconsistent results each time I run the program: the program is very
simple and it should insert some data using separate threads and read all
that data once the insertion is complete. The issue is that sometimes the
{ "_id" : { "$oid" : "5be200e156acbb414f462a62" }, "id" : 1, "name" : "a" }
{ "_id" : { "$oid" : "5be200e156acbb414f462a63" }, "id" : 2, "name" : "b" }
{ "_id" : { "$oid" : "5be200e156acbb414f462a64" }, "id" : 3, "name" : "c" }
{ "_id" : { "$oid" : "5be200e156acbb414f462a65" }, "id" : 4, "name" : "d" }
{ "_id" : { "$oid" : "5be200e156acbb414f462a66" }, "id" : 5, "name" : "e" }
{ "_id" : { "$oid" : "5be200e156acbb414f462a67" }, "id" : 6, "name" : "f" }
Process finished with exit code 11
{ "_id" : { "$oid" : "5be2038156acbb43c05f5ab2" }, "id" : 2, "name" : "b" }
{ "_id" : { "$oid" : "5be2038156acbb43c05f5ab4" }, "id" : 3, "name" : "c" }
{ "_id" : { "$oid" : "5be2038156acbb43c05f5ab6" }, "id" : 5, "name" : "e" }
{ "_id" : { "$oid" : "5be2038156acbb43c05f5ab7" }, "id" : 6, "name" : "f" }
I can't spot the source of the error in my program, there is probably an
error my c++ programming (my c++ is a bit rusty rsrs). In attachment you
can find the program (it is a very simple main function).
Thank you all,
Br,
Rodrigo
--
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/858c87ba-c049-44f7-b146-f87976569ef0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Rodrigo Broggi
2018-11-07 12:39:04 UTC
Permalink
Every now and then the program outcome is:

mongo-c-driver-1.13.0/src/libbson/src/bson/bson-utf8.c:124
bson_utf8_validate(): precondition failed: utf8

Process finished with exit code 6


BR,

Rodrigo
Post by Rodrigo Broggi
Hi all,
I've been playing around with mongo-cxx-driver since I would like to
become a contributor. After following the driver tutorial I've setup a toy
program to interact with my local mongod instance. The weird part is that I
have inconsistent results each time I run the program: the program is very
simple and it should insert some data using separate threads and read all
that data once the insertion is complete. The issue is that sometimes the
{ "_id" : { "$oid" : "5be200e156acbb414f462a62" }, "id" : 1, "name" : "a" }
{ "_id" : { "$oid" : "5be200e156acbb414f462a63" }, "id" : 2, "name" : "b" }
{ "_id" : { "$oid" : "5be200e156acbb414f462a64" }, "id" : 3, "name" : "c" }
{ "_id" : { "$oid" : "5be200e156acbb414f462a65" }, "id" : 4, "name" : "d" }
{ "_id" : { "$oid" : "5be200e156acbb414f462a66" }, "id" : 5, "name" : "e" }
{ "_id" : { "$oid" : "5be200e156acbb414f462a67" }, "id" : 6, "name" : "f" }
Process finished with exit code 11
{ "_id" : { "$oid" : "5be2038156acbb43c05f5ab2" }, "id" : 2, "name" : "b" }
{ "_id" : { "$oid" : "5be2038156acbb43c05f5ab4" }, "id" : 3, "name" : "c" }
{ "_id" : { "$oid" : "5be2038156acbb43c05f5ab6" }, "id" : 5, "name" : "e" }
{ "_id" : { "$oid" : "5be2038156acbb43c05f5ab7" }, "id" : 6, "name" : "f" }
I can't spot the source of the error in my program, there is probably an
error my c++ programming (my c++ is a bit rusty rsrs). In attachment you
can find the program (it is a very simple main function).
Thank you all,
Br,
Rodrigo
--
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/eafc995e-e31e-4886-a970-f990a06f60db%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Rodrigo Broggi
2018-11-07 12:49:07 UTC
Permalink
Hi all,

You can also find a github repo
<https://github.com/rbroggi/mongo-cxx-driver-test> of how to build/compile
the project (using cmake). Some of my local paths are hardcoded in the
readme.md but you can replace them with whatever fits your needs.

BR,

Rodrigo
Post by Rodrigo Broggi
Hi all,
I've been playing around with mongo-cxx-driver since I would like to
become a contributor. After following the driver tutorial I've setup a toy
program to interact with my local mongod instance. The weird part is that I
have inconsistent results each time I run the program: the program is very
simple and it should insert some data using separate threads and read all
that data once the insertion is complete. The issue is that sometimes the
{ "_id" : { "$oid" : "5be200e156acbb414f462a62" }, "id" : 1, "name" : "a" }
{ "_id" : { "$oid" : "5be200e156acbb414f462a63" }, "id" : 2, "name" : "b" }
{ "_id" : { "$oid" : "5be200e156acbb414f462a64" }, "id" : 3, "name" : "c" }
{ "_id" : { "$oid" : "5be200e156acbb414f462a65" }, "id" : 4, "name" : "d" }
{ "_id" : { "$oid" : "5be200e156acbb414f462a66" }, "id" : 5, "name" : "e" }
{ "_id" : { "$oid" : "5be200e156acbb414f462a67" }, "id" : 6, "name" : "f" }
Process finished with exit code 11
{ "_id" : { "$oid" : "5be2038156acbb43c05f5ab2" }, "id" : 2, "name" : "b" }
{ "_id" : { "$oid" : "5be2038156acbb43c05f5ab4" }, "id" : 3, "name" : "c" }
{ "_id" : { "$oid" : "5be2038156acbb43c05f5ab6" }, "id" : 5, "name" : "e" }
{ "_id" : { "$oid" : "5be2038156acbb43c05f5ab7" }, "id" : 6, "name" : "f" }
I can't spot the source of the error in my program, there is probably an
error my c++ programming (my c++ is a bit rusty rsrs). In attachment you
can find the program (it is a very simple main function).
Thank you all,
Br,
Rodrigo
--
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/0336d074-525a-4648-8da1-5be627c853d4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
'Andrew Morrow' via mongodb-user
2018-11-07 14:10:30 UTC
Permalink
Hi Rodrigo -

I'd like to suggest that you run your program under Valgrind or
AddressSanitizer. I strongly suspect that you are retaining views into
deleted documents, and either of those tools will make errors of that sort
immediately clear. Valgrind is probably easiest to start with since you
don't need to recompile your binary.

Thanks,
Andrew
Post by Rodrigo Broggi
Hi all,
You can also find a github repo
<https://github.com/rbroggi/mongo-cxx-driver-test> of how to
build/compile the project (using cmake). Some of my local paths are
hardcoded in the readme.md but you can replace them with whatever fits your
needs.
BR,
Rodrigo
Post by Rodrigo Broggi
Hi all,
I've been playing around with mongo-cxx-driver since I would like to
become a contributor. After following the driver tutorial I've setup a toy
program to interact with my local mongod instance. The weird part is that I
have inconsistent results each time I run the program: the program is very
simple and it should insert some data using separate threads and read all
that data once the insertion is complete. The issue is that sometimes the
{ "_id" : { "$oid" : "5be200e156acbb414f462a62" }, "id" : 1, "name" : "a" }
{ "_id" : { "$oid" : "5be200e156acbb414f462a63" }, "id" : 2, "name" : "b" }
{ "_id" : { "$oid" : "5be200e156acbb414f462a64" }, "id" : 3, "name" : "c" }
{ "_id" : { "$oid" : "5be200e156acbb414f462a65" }, "id" : 4, "name" : "d" }
{ "_id" : { "$oid" : "5be200e156acbb414f462a66" }, "id" : 5, "name" : "e" }
{ "_id" : { "$oid" : "5be200e156acbb414f462a67" }, "id" : 6, "name" : "f" }
Process finished with exit code 11
{ "_id" : { "$oid" : "5be2038156acbb43c05f5ab2" }, "id" : 2, "name" : "b" }
{ "_id" : { "$oid" : "5be2038156acbb43c05f5ab4" }, "id" : 3, "name" : "c" }
{ "_id" : { "$oid" : "5be2038156acbb43c05f5ab6" }, "id" : 5, "name" : "e" }
{ "_id" : { "$oid" : "5be2038156acbb43c05f5ab7" }, "id" : 6, "name" : "f" }
I can't spot the source of the error in my program, there is probably an
error my c++ programming (my c++ is a bit rusty rsrs). In attachment you
can find the program (it is a very simple main function).
Thank you all,
Br,
Rodrigo
--
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/0336d074-525a-4648-8da1-5be627c853d4%40googlegroups.com
<https://groups.google.com/d/msgid/mongodb-user/0336d074-525a-4648-8da1-5be627c853d4%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/CAHX05qEBiK7GDgb8quAeRO3xVkyq-j9eqOsX%2BWG_e-P4KuXSnA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Rodrigo Broggi
2018-11-09 23:45:00 UTC
Permalink
Hi Andrew,

First of all, thank you for helping me out. For some reason I lost your
message on Wednesday but, either way I wouldn't have been able to do so on
Thursday or Friday because I've been late in the office the last few
days... I will certainly try it and let you know.

Thank you and best regards,

Rodrigo


On Wed, Nov 7, 2018 at 3:10 PM 'Andrew Morrow' via mongodb-user <
Post by 'Andrew Morrow' via mongodb-user
Hi Rodrigo -
I'd like to suggest that you run your program under Valgrind or
AddressSanitizer. I strongly suspect that you are retaining views into
deleted documents, and either of those tools will make errors of that sort
immediately clear. Valgrind is probably easiest to start with since you
don't need to recompile your binary.
Thanks,
Andrew
Post by Rodrigo Broggi
Hi all,
You can also find a github repo
<https://github.com/rbroggi/mongo-cxx-driver-test> of how to
build/compile the project (using cmake). Some of my local paths are
hardcoded in the readme.md but you can replace them with whatever fits your
needs.
BR,
Rodrigo
Post by Rodrigo Broggi
Hi all,
I've been playing around with mongo-cxx-driver since I would like to
become a contributor. After following the driver tutorial I've setup a toy
program to interact with my local mongod instance. The weird part is that I
have inconsistent results each time I run the program: the program is very
simple and it should insert some data using separate threads and read all
that data once the insertion is complete. The issue is that sometimes the
{ "_id" : { "$oid" : "5be200e156acbb414f462a62" }, "id" : 1, "name" : "a" }
{ "_id" : { "$oid" : "5be200e156acbb414f462a63" }, "id" : 2, "name" : "b" }
{ "_id" : { "$oid" : "5be200e156acbb414f462a64" }, "id" : 3, "name" : "c" }
{ "_id" : { "$oid" : "5be200e156acbb414f462a65" }, "id" : 4, "name" : "d" }
{ "_id" : { "$oid" : "5be200e156acbb414f462a66" }, "id" : 5, "name" : "e" }
{ "_id" : { "$oid" : "5be200e156acbb414f462a67" }, "id" : 6, "name" : "f" }
Process finished with exit code 11
{ "_id" : { "$oid" : "5be2038156acbb43c05f5ab2" }, "id" : 2, "name" : "b" }
{ "_id" : { "$oid" : "5be2038156acbb43c05f5ab4" }, "id" : 3, "name" : "c" }
{ "_id" : { "$oid" : "5be2038156acbb43c05f5ab6" }, "id" : 5, "name" : "e" }
{ "_id" : { "$oid" : "5be2038156acbb43c05f5ab7" }, "id" : 6, "name" : "f" }
I can't spot the source of the error in my program, there is probably an
error my c++ programming (my c++ is a bit rusty rsrs). In attachment you
can find the program (it is a very simple main function).
Thank you all,
Br,
Rodrigo
--
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/0336d074-525a-4648-8da1-5be627c853d4%40googlegroups.com
<https://groups.google.com/d/msgid/mongodb-user/0336d074-525a-4648-8da1-5be627c853d4%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.
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/CAHX05qEBiK7GDgb8quAeRO3xVkyq-j9eqOsX%2BWG_e-P4KuXSnA%40mail.gmail.com
<https://groups.google.com/d/msgid/mongodb-user/CAHX05qEBiK7GDgb8quAeRO3xVkyq-j9eqOsX%2BWG_e-P4KuXSnA%40mail.gmail.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/CADacLN5mHUkABRa1ZXDccGMyE%3DpSvHSJ9V2zmOd044TvpHfTPw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Bob Cochran
2018-11-10 00:26:15 UTC
Permalink
Valgrind is easy to compile from source code. I suggest cloning it from the Valgrind git repository instead of downloading a tarball from the public download site. I was able to do this, compile and install to my own home directory in less than 10 minutes. Valgrind has excellent documentation too.

Thanks so much

Bob
Post by Rodrigo Broggi
Hi Andrew,
First of all, thank you for helping me out. For some reason I lost your message on Wednesday but, either way I wouldn't have been able to do so on Thursday or Friday because I've been late in the office the last few days... I will certainly try it and let you know.
Thank you and best regards,
Rodrigo
Post by 'Andrew Morrow' via mongodb-user
Hi Rodrigo -
I'd like to suggest that you run your program under Valgrind or AddressSanitizer. I strongly suspect that you are retaining views into deleted documents, and either of those tools will make errors of that sort immediately clear. Valgrind is probably easiest to start with since you don't need to recompile your binary.
Thanks,
Andrew
Post by Rodrigo Broggi
Hi all,
You can also find a github repo of how to build/compile the project (using cmake). Some of my local paths are hardcoded in the readme.md but you can replace them with whatever fits your needs.
BR,
Rodrigo
Post by Rodrigo Broggi
Hi all,
{ "_id" : { "$oid" : "5be200e156acbb414f462a62" }, "id" : 1, "name" : "a" }
{ "_id" : { "$oid" : "5be200e156acbb414f462a63" }, "id" : 2, "name" : "b" }
{ "_id" : { "$oid" : "5be200e156acbb414f462a64" }, "id" : 3, "name" : "c" }
{ "_id" : { "$oid" : "5be200e156acbb414f462a65" }, "id" : 4, "name" : "d" }
{ "_id" : { "$oid" : "5be200e156acbb414f462a66" }, "id" : 5, "name" : "e" }
{ "_id" : { "$oid" : "5be200e156acbb414f462a67" }, "id" : 6, "name" : "f" }
Process finished with exit code 11
{ "_id" : { "$oid" : "5be2038156acbb43c05f5ab2" }, "id" : 2, "name" : "b" }
{ "_id" : { "$oid" : "5be2038156acbb43c05f5ab4" }, "id" : 3, "name" : "c" }
{ "_id" : { "$oid" : "5be2038156acbb43c05f5ab6" }, "id" : 5, "name" : "e" }
{ "_id" : { "$oid" : "5be2038156acbb43c05f5ab7" }, "id" : 6, "name" : "f" }
I can't spot the source of the error in my program, there is probably an error my c++ programming (my c++ is a bit rusty rsrs). In attachment you can find the program (it is a very simple main function).
Thank you all,
Br,
Rodrigo
--
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.
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/0336d074-525a-4648-8da1-5be627c853d4%40googlegroups.com.
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.
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/CAHX05qEBiK7GDgb8quAeRO3xVkyq-j9eqOsX%2BWG_e-P4KuXSnA%40mail.gmail.com.
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.
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/CADacLN5mHUkABRa1ZXDccGMyE%3DpSvHSJ9V2zmOd044TvpHfTPw%40mail.gmail.com.
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/FB21F509-566C-4B54-87C5-B2E52E44F3F5%40gmail.com.
For more options, visit https://groups.google.com/d/optout.
Rodrigo Broggi
2018-11-10 01:37:51 UTC
Permalink
Hi Bob, All,

Thank you for the suggestion, I happen to have Valgrind installed and
unfortunately by simply running memcheck (below the Valgrin options
activated) I couldn't verify warning/errors in my code:

/usr/local/bin/valgrind --tool=memcheck --xml=yes --xml-file=/private/var/
folders/0x/pq4d230x0v795s_3gp3vzdw00000gn/T/valgrind --gen-suppressions=all
--leak-check=full --leak-resolution=med --track-origins=yes /Users/
rodrigobroggi/Documents/Workspace/cpp/mongo/mongo-test/mongo_test

To double-check if Valgrind was working I've introduced a very simple mem
leak to see if it would be catch (and it did), see the screenshot of CLion
IDE attached.

As you can see from the screen shot, apart from the naive memleak, nothing
else in my code "mongo_test.cpp" has been identified.

Any other hints?

Thank you a lot,

Rodrigo Broggi
Post by Rodrigo Broggi
Hi all,
I've been playing around with mongo-cxx-driver since I would like to
become a contributor. After following the driver tutorial I've setup a toy
program to interact with my local mongod instance. The weird part is that I
have inconsistent results each time I run the program: the program is very
simple and it should insert some data using separate threads and read all
that data once the insertion is complete. The issue is that sometimes the
{ "_id" : { "$oid" : "5be200e156acbb414f462a62" }, "id" : 1, "name" : "a" }
{ "_id" : { "$oid" : "5be200e156acbb414f462a63" }, "id" : 2, "name" : "b" }
{ "_id" : { "$oid" : "5be200e156acbb414f462a64" }, "id" : 3, "name" : "c" }
{ "_id" : { "$oid" : "5be200e156acbb414f462a65" }, "id" : 4, "name" : "d" }
{ "_id" : { "$oid" : "5be200e156acbb414f462a66" }, "id" : 5, "name" : "e" }
{ "_id" : { "$oid" : "5be200e156acbb414f462a67" }, "id" : 6, "name" : "f" }
Process finished with exit code 11
{ "_id" : { "$oid" : "5be2038156acbb43c05f5ab2" }, "id" : 2, "name" : "b" }
{ "_id" : { "$oid" : "5be2038156acbb43c05f5ab4" }, "id" : 3, "name" : "c" }
{ "_id" : { "$oid" : "5be2038156acbb43c05f5ab6" }, "id" : 5, "name" : "e" }
{ "_id" : { "$oid" : "5be2038156acbb43c05f5ab7" }, "id" : 6, "name" : "f" }
I can't spot the source of the error in my program, there is probably an
error my c++ programming (my c++ is a bit rusty rsrs). In attachment you
can find the program (it is a very simple main function).
Thank you all,
Br,
Rodrigo
--
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/bfdec34c-0eb7-4f66-b3ff-bb8471af12e7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
'Andrew Morrow' via mongodb-user
2018-11-10 03:24:34 UTC
Permalink
I'm not sure why valgrind isn't showing it, but I'm fairly sure your
retrieve function is illegal. The views you get back from a
cursor::iterator are only good until you increment the cursor. You need to
promote them to document values if you want to keep them around longer.
Post by Rodrigo Broggi
Hi Bob, All,
Thank you for the suggestion, I happen to have Valgrind installed and
unfortunately by simply running memcheck (below the Valgrin options
/usr/local/bin/valgrind --tool=memcheck --xml=yes --xml-file=/private/var/
folders/0x/pq4d230x0v795s_3gp3vzdw00000gn/T/valgrind --gen-suppressions=all
--leak-check=full --leak-resolution=med --track-origins=yes /Users/
rodrigobroggi/Documents/Workspace/cpp/mongo/mongo-test/mongo_test
To double-check if Valgrind was working I've introduced a very simple mem
leak to see if it would be catch (and it did), see the screenshot of CLion
IDE attached.
As you can see from the screen shot, apart from the naive memleak, nothing
else in my code "mongo_test.cpp" has been identified.
Any other hints?
Thank you a lot,
Rodrigo Broggi
Post by Rodrigo Broggi
Hi all,
I've been playing around with mongo-cxx-driver since I would like to
become a contributor. After following the driver tutorial I've setup a toy
program to interact with my local mongod instance. The weird part is that I
have inconsistent results each time I run the program: the program is very
simple and it should insert some data using separate threads and read all
that data once the insertion is complete. The issue is that sometimes the
{ "_id" : { "$oid" : "5be200e156acbb414f462a62" }, "id" : 1, "name" : "a" }
{ "_id" : { "$oid" : "5be200e156acbb414f462a63" }, "id" : 2, "name" : "b" }
{ "_id" : { "$oid" : "5be200e156acbb414f462a64" }, "id" : 3, "name" : "c" }
{ "_id" : { "$oid" : "5be200e156acbb414f462a65" }, "id" : 4, "name" : "d" }
{ "_id" : { "$oid" : "5be200e156acbb414f462a66" }, "id" : 5, "name" : "e" }
{ "_id" : { "$oid" : "5be200e156acbb414f462a67" }, "id" : 6, "name" : "f" }
Process finished with exit code 11
{ "_id" : { "$oid" : "5be2038156acbb43c05f5ab2" }, "id" : 2, "name" : "b" }
{ "_id" : { "$oid" : "5be2038156acbb43c05f5ab4" }, "id" : 3, "name" : "c" }
{ "_id" : { "$oid" : "5be2038156acbb43c05f5ab6" }, "id" : 5, "name" : "e" }
{ "_id" : { "$oid" : "5be2038156acbb43c05f5ab7" }, "id" : 6, "name" : "f" }
I can't spot the source of the error in my program, there is probably an
error my c++ programming (my c++ is a bit rusty rsrs). In attachment you
can find the program (it is a very simple main function).
Thank you all,
Br,
Rodrigo
--
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/bfdec34c-0eb7-4f66-b3ff-bb8471af12e7%40googlegroups.com
<https://groups.google.com/d/msgid/mongodb-user/bfdec34c-0eb7-4f66-b3ff-bb8471af12e7%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/CAHX05qGyg5oDmMEZFducF5ioPs1HN1mWLDz2FBc4_9ro3nyYFQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Robert Cochran
2018-11-10 03:36:05 UTC
Permalink
Andrew is giving really good advice here. And I'd definitely freshen your
Valgrind version. I use OS X as well, and I generally have my own private
bin directory for code that I compile myself. That way I can benefit from
the latest versions of software.

Then again -- OS X and Apple are different from Linux.

I would definitely follow up with Andrew's advice.

Bob
Post by 'Andrew Morrow' via mongodb-user
I'm not sure why valgrind isn't showing it, but I'm fairly sure your
retrieve function is illegal. The views you get back from a
cursor::iterator are only good until you increment the cursor. You need to
promote them to document values if you want to keep them around longer.
Post by Rodrigo Broggi
Hi Bob, All,
Thank you for the suggestion, I happen to have Valgrind installed and
unfortunately by simply running memcheck (below the Valgrin options
/usr/local/bin/valgrind --tool=memcheck --xml=yes --xml-file=/private/var
/folders/0x/pq4d230x0v795s_3gp3vzdw00000gn/T/valgrind --gen-suppressions=all
--leak-check=full --leak-resolution=med --track-origins=yes /Users/
rodrigobroggi/Documents/Workspace/cpp/mongo/mongo-test/mongo_test
To double-check if Valgrind was working I've introduced a very simple mem
leak to see if it would be catch (and it did), see the screenshot of CLion
IDE attached.
As you can see from the screen shot, apart from the naive memleak,
nothing else in my code "mongo_test.cpp" has been identified.
Any other hints?
Thank you a lot,
Rodrigo Broggi
Post by Rodrigo Broggi
Hi all,
I've been playing around with mongo-cxx-driver since I would like to
become a contributor. After following the driver tutorial I've setup a toy
program to interact with my local mongod instance. The weird part is that I
have inconsistent results each time I run the program: the program is very
simple and it should insert some data using separate threads and read all
that data once the insertion is complete. The issue is that sometimes the
{ "_id" : { "$oid" : "5be200e156acbb414f462a62" }, "id" : 1, "name" : "a" }
{ "_id" : { "$oid" : "5be200e156acbb414f462a63" }, "id" : 2, "name" : "b" }
{ "_id" : { "$oid" : "5be200e156acbb414f462a64" }, "id" : 3, "name" : "c" }
{ "_id" : { "$oid" : "5be200e156acbb414f462a65" }, "id" : 4, "name" : "d" }
{ "_id" : { "$oid" : "5be200e156acbb414f462a66" }, "id" : 5, "name" : "e" }
{ "_id" : { "$oid" : "5be200e156acbb414f462a67" }, "id" : 6, "name" : "f" }
Process finished with exit code 11
{ "_id" : { "$oid" : "5be2038156acbb43c05f5ab2" }, "id" : 2, "name" : "b" }
{ "_id" : { "$oid" : "5be2038156acbb43c05f5ab4" }, "id" : 3, "name" : "c" }
{ "_id" : { "$oid" : "5be2038156acbb43c05f5ab6" }, "id" : 5, "name" : "e" }
{ "_id" : { "$oid" : "5be2038156acbb43c05f5ab7" }, "id" : 6, "name" : "f" }
I can't spot the source of the error in my program, there is probably an
error my c++ programming (my c++ is a bit rusty rsrs). In attachment you
can find the program (it is a very simple main function).
Thank you all,
Br,
Rodrigo
--
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
<javascript:>.
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/bfdec34c-0eb7-4f66-b3ff-bb8471af12e7%40googlegroups.com
<https://groups.google.com/d/msgid/mongodb-user/bfdec34c-0eb7-4f66-b3ff-bb8471af12e7%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/36c6f45c-d08f-4841-bd71-4447b4647fea%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Rodrigo Broggi
2018-11-10 21:43:53 UTC
Permalink
Dears Andrew, Bob, all,

I wanted to thank you for the valuable suggestions: at the end the problem
was indeed related to what Andrew spot: the view data structure expires at
the end of the loop and so there was a bunch of Valgrind "invalid reads" in
the retrieve part. I've been a Java/Kotlin/Go developer in the last 5 years
and I will have to reacquire the sensibility and experience on memory
management again. In the meanwhile thank you again and have a great
weekend.

The corrected code can be found under the:

https://github.com/rbroggi/mongo-cxx-driver-test/blob/master/mongo_test.cpp

BR,

Rodrigo Broggi
Post by Rodrigo Broggi
Hi all,
I've been playing around with mongo-cxx-driver since I would like to
become a contributor. After following the driver tutorial I've setup a toy
program to interact with my local mongod instance. The weird part is that I
have inconsistent results each time I run the program: the program is very
simple and it should insert some data using separate threads and read all
that data once the insertion is complete. The issue is that sometimes the
{ "_id" : { "$oid" : "5be200e156acbb414f462a62" }, "id" : 1, "name" : "a" }
{ "_id" : { "$oid" : "5be200e156acbb414f462a63" }, "id" : 2, "name" : "b" }
{ "_id" : { "$oid" : "5be200e156acbb414f462a64" }, "id" : 3, "name" : "c" }
{ "_id" : { "$oid" : "5be200e156acbb414f462a65" }, "id" : 4, "name" : "d" }
{ "_id" : { "$oid" : "5be200e156acbb414f462a66" }, "id" : 5, "name" : "e" }
{ "_id" : { "$oid" : "5be200e156acbb414f462a67" }, "id" : 6, "name" : "f" }
Process finished with exit code 11
{ "_id" : { "$oid" : "5be2038156acbb43c05f5ab2" }, "id" : 2, "name" : "b" }
{ "_id" : { "$oid" : "5be2038156acbb43c05f5ab4" }, "id" : 3, "name" : "c" }
{ "_id" : { "$oid" : "5be2038156acbb43c05f5ab6" }, "id" : 5, "name" : "e" }
{ "_id" : { "$oid" : "5be2038156acbb43c05f5ab7" }, "id" : 6, "name" : "f" }
I can't spot the source of the error in my program, there is probably an
error my c++ programming (my c++ is a bit rusty rsrs). In attachment you
can find the program (it is a very simple main function).
Thank you all,
Br,
Rodrigo
--
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/bc6e225e-f4c3-4c21-ae33-f4248155f73b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Continue reading on narkive:
Loading...