当我尝试使用 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"