-
Type:
Bug
-
Resolution: Duplicate
-
Priority:
Major - P3
-
None
-
Affects Version/s: 1.1.6, 1.1.10
-
Component/s: libmongoc
-
None
-
None
-
None
-
None
-
None
-
None
-
None
Hello,
This simple C program
test.c
#include <mongoc.h>
#include <stdio.h>
mongoc_client_pool_t *client_pool;
void mongodb_new()
{
mongoc_client_t *client;
const char *uristr = "mongodb://127.0.0.1/";
mongoc_init ();
client = mongoc_client_new (uristr);
if (!client) {
fprintf (stderr, "Failed to parse URI.\n");
}
}
void mongodb_delete()
{
mongoc_client_pool_destroy(client_pool);
mongoc_cleanup();
}
int main (int argc, char *argv[])
{
mongodb_new();
//mongodb_delete();
}
compiled as:
gcc ./test.c -o test -lmongoc-1.0 -I/usr/local/include/libmongoc-1.0 -I/usr/local/include/libbson-1.0
throws segmentation fault when run under Valgrind:
valgrind --leak-check=yes ./test
See output below:
2015/07/31 17:47:26.0543: [ 6989]: DEBUG: cluster: Client initialized in direct mode. ==6989== Jump to the invalid address stated on the next line ==6989== at 0xFFFFFFFFFF600800: ??? ==6989== by 0x4006E4: mongodb_new (in /appl/INSTALL/ESBArchivingLogging/aggr/src/test) ==6989== by 0x400749: main (in /appl/INSTALL/ESBArchivingLogging/aggr/src/test) ==6989== Address 0xffffffffff600800 is not stack'd, malloc'd or (recently) free'd ==6989== ==6989== ==6989== Process terminating with default action of signal 11 (SIGSEGV): dumping core ==6989== Bad permissions for mapped region at address 0xFFFFFFFFFF600800 ==6989== at 0xFFFFFFFFFF600800: ??? ==6989== by 0x4006E4: mongodb_new (in /appl/INSTALL/ESBArchivingLogging/aggr/src/test) ==6989== by 0x400749: main (in /appl/INSTALL/ESBArchivingLogging/aggr/src/test) ==6989== ==6989== HEAP SUMMARY: ==6989== in use at exit: 3,930 bytes in 13 blocks ==6989== total heap usage: 39 allocs, 26 frees, 6,294 bytes allocated ==6989== ==6989== 3,930 (192 direct, 3,738 indirect) bytes in 1 blocks are definitely lost in loss record 13 of 13 ==6989== at 0x4A04A28: calloc (vg_replace_malloc.c:467) ==6989== by 0x4E59816: bson_malloc0 (in /usr/local/lib/libbson-1.0.so.0.0.0) ==6989== by 0x4C2361D: mongoc_client_new (in /usr/local/lib/libmongoc-1.0.so.0.0.0) ==6989== by 0x4006E4: mongodb_new (in /appl/INSTALL/ESBArchivingLogging/aggr/src/test) ==6989== by 0x400749: main (in /appl/INSTALL/ESBArchivingLogging/aggr/src/test) ==6989== ==6989== LEAK SUMMARY: ==6989== definitely lost: 192 bytes in 1 blocks ==6989== indirectly lost: 3,738 bytes in 12 blocks ==6989== possibly lost: 0 bytes in 0 blocks ==6989== still reachable: 0 bytes in 0 blocks ==6989== suppressed: 0 bytes in 0 blocks ==6989== ==6989== For counts of detected and suppressed errors, rerun with: -v ==6989== ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 6 from 6) Segmentation fault
Any idea what is wrong?
Thank you in advance for help.
Regards
Jan
- is related to
-
CDRIVER-773 Segmentation fault during driver initialization
-
- Closed
-