0

When I try to use libmongoc, I get a segfault at

client = mongoc_client_new ("mongodb://localhost:27017");

GDB results:

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

I've tried a lot of things, but am so far unsucessfull in solving the issue. Any help would be appreciated.

EDIT: It doesn't seem to be a problem with my code, as far as I know I'm calling mongc_client_new correctly.

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"
  • Does this happen immediately or after 30 seconds or so? Is there a `mongod` process listening on 27017 on the local machine? – Pete Garafano Mar 08 '18 at 21:25
  • It happens immediately, `netstat -tulpn` outputs `tcp 0 0 127.0.0.1:27017 0.0.0.0:* LISTEN 15127/mongod` – Denzel Haverkamp Mar 09 '18 at 11:00
  • I'm running the exact same code on a different pc and it works just fine, Maybe there's a problem with the installation, but i've reinstalled it multiple times already – Denzel Haverkamp Mar 09 '18 at 13:43
  • If this code works on one system and not another, it would be prudent to ask "what's different?" – Pete Garafano Mar 09 '18 at 15:29
  • 1
    I wish I knew, I followed the exact same steps. The only difference is that the one that works is on a laptop and the one that doesn't work is on a VPS – Denzel Haverkamp Mar 09 '18 at 16:28
  • It's hard to say without poking around the system, but i would look at things that affect connectivity, perhaps one has auth enabled and the other does not? one has a firewall and the other does not? – Pete Garafano Mar 09 '18 at 16:50
  • I'm trying to find a difference, but can't find any. What error would I normally get if the specified ip was incorrect? No matter what I enter, i still get the same error. – Denzel Haverkamp Mar 09 '18 at 20:20
  • @PeteGarafano The edit doesn't clarify things for me, but maybe it's useful to you. – Denzel Haverkamp Mar 10 '18 at 12:04

0 Answers0