当使用libmongoc时,我在`client = mongoc_client_new(" mongodb:// localhost:27017")中得到一个段错误;

时间:2018-03-08 21:14:30

标签: mongodb mongo-c-driver

当我尝试使用libmongoc时,我在

处遇到了段错误
client = mongoc_client_new ("mongodb://localhost:27017");

GDB结果:

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff7970d79 in _mongoc_client_new_from_uri () from 
/usr/local/lib/libmongoc-1.0.so.0
(gdb) backtrace
0  0x00007ffff7970d79 in _mongoc_client_new_from_uri () from 
/usr/local/lib/libmongoc-1.0.so.0
#1  0x00007ffff7970e57 in mongoc_client_new () from /usr/local/lib/libmongoc- 
1.0.so.0
#2  0x0000000000401632 in handlerMain (UID=0x7fffffffe420 "12\n") at 
handler.c:57
#3  0x0000000000402e70 in reciever (run=1) at server.c:61
#4  0x0000000000402fd8 in main () at server.c:89

我已经尝试了很多东西,但到目前为止还没有解决这个问题。 任何帮助将不胜感激。

编辑: 我的代码似乎没有问题,据我所知,我正在正确地调用mongc_client_new

Core was generated by ./server.
Program terminated with signal SIGSEGV, Segmentation fault.
0  0x00007fd680bb1d79 in _mongoc_client_new_from_uri () from /usr/local/lib/libmongoc-1.0.so.0
(gdb) backtrace
#0  0x00007fd680bb1d79 in _mongoc_client_new_from_uri () from /usr/local/lib/libmongoc-1.0.so.0
#1  0x00007fd680bb1e57 in mongoc_client_new () from /usr/local/lib/libmongoc-1.0.so.0
#2  0x0000000000401646 in handlerMain (UID=0x7ffe76514530 "8fc1ae29") at handler.c:59
#3  0x0000000000402e9d in reciever (run=1) at server.c:62
#4  0x0000000000403005 in main () at server.c:90
(gdb) up
#1  0x00007fd680bb1e57 in mongoc_client_new () from /usr/local/lib/libmongoc-1.0.so.0
(gdb) up
#2  0x0000000000401646 in handlerMain (UID=0x7ffe76514530 "8fc1ae29") at handler.c:59
59              client = mongoc_client_new (uri_str);
(gdb) print uri_str
$1 = 0x4030dc "mongodb://127.0.0.1:27017"

0 个答案:

没有答案