[SERVER-7594] xamples/tutorial.cpp throws assertion src/mongo/client/dbclientinterface.h:1105 Created: 08/Nov/12  Updated: 01/Apr/13  Resolved: 09/Nov/12

Status: Closed
Project: Core Server
Component/s: Internal Client
Affects Version/s: 2.2.1
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Mathias Rohnstock Assignee: Eric Milkie
Resolution: Done Votes: 0
Labels: connection
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Debian Squeeze x86_64
MongoDB 2.2.1 Server (from 10gen repo) and cxx-driver (from http://downloads.mongodb.org/cxx-driver/mongodb-linux-x86_64-2.2.1.tgz)


Issue Links:
Duplicate
is duplicated by SERVER-8212 CXX-Driver: examples/tutorial.cpp thr... Closed
Operating System: Linux
Participants:

 Description   

(already written this issue to drivers-project, but I think, it fits better here)

cxx-driver installed with

scons install

installation and compilation works streight forward, but I can't get the examples/tutorial.cpp working as descripted here: http://www.mongodb.org/pages/viewpage.action?pageId=133415#C%2B%2BTutorial-Connecting
example compiled with

g++ tutorial.cpp -pthread -lmongoclient -lboost_thread-mt -lboost_filesystem -lboost_program_options -lboost_system -o tutorial

compilation returns no errors, too.
on executing ./tutorial the following appear:

$ ./tutorial
Thu Nov 8 14:22:12 Assertion failure p src/mongo/client/dbclientinterface.h 1105
caught assertion src/mongo/client/dbclientinterface.h:1105

Don't know, what I can do against it?
Thanks!

  • Mathias


 Comments   
Comment by Eric Milkie [ 09/Nov/12 ]

Thank you for discovering that!

Comment by Mathias Rohnstock [ 09/Nov/12 ]

ha...!

I found the issue... there was already an other libmongoclient.a in /usr/lib
scons installs the compiled libmongoclient.a to /usr/local/lib

I've removed the libmongoclient.a from /usr/lib and recompiled the examples and everything works .

THANK YOU VERY MUCH FOR YOUR HELP!

Don't know, how this library gots located there?... what ever... I'm happy now

Comment by Mathias Rohnstock [ 09/Nov/12 ]

every example compiles without errors

./first:

Fri Nov  9 17:44:55 DBClientCursor::init message from call() was empty
using cursor
Segmentation fault

./second:

using cursor
	{ "_id" : { "$oid" : "509d32ffd5c7ae20b54278e7" }, "name" : "eliot", "num" : 17 }
	{ "_id" : { "$oid" : "509d32ffd5c7ae20b54278e8" }, "name" : "sara", "num" : 24 }

./firstClient:

Fri Nov  9 17:46:25 DBClientCursor::init message from call() was empty
terminate called after throwing an instance of 'mongo::UserException'
  what():  DBClientBase::findN: transport error: 127.0.0.1:27017 ns: test.$cmd query: { drop: "test1" }
Aborted

looks like, that the "second" example runs without errors?

Comment by Eric Milkie [ 09/Nov/12 ]

Do "first", "second", and "clientTest" have the same assertion error? They are in the same directory as "tutorial".
I'm having trouble figuring out where your issue is. When I run 'tutorial' myself, execution never hits the line with the assert (I changed it to always abort when it hits that line).

Comment by Mathias Rohnstock [ 09/Nov/12 ]

Hi,
no issues so far, could connect and query to the database what I want with mongo(-shell).
I'm also using a php-based site, which connects to this database, without errors.

Comment by Eric Milkie [ 09/Nov/12 ]

Does the mongo shell connect okay when you run it, or does it give a similar error?

Comment by Mathias Rohnstock [ 09/Nov/12 ]

Thanks Eric,

I've given it a try, but ends in the same result .

Comment by Eric Milkie [ 09/Nov/12 ]

It sounds like you might be having trouble connecting to "localhost". Can you try changing the connection string on tutorial.cpp:36 to your computer's IP address?

Comment by Mathias Rohnstock [ 09/Nov/12 ]

with "mongodb-linux-x86_64-v2.2-latest" the same happen.

Comment by Mathias Rohnstock [ 09/Nov/12 ]

Hi, thanks for reply.
I've rechecked the headers and the 2.2.1 headers got copied to /usr/local/include/mongo.

I've removed the whole directory and tried to compile the example, which returned:

tutorial.cpp:19:35: error: mongo/client/dbclient.h: No such file or directory
tutorial.cpp:24: error: ‘mongo’ is not a namespace-name
tutorial.cpp:24: error: expected namespace-name before ‘;’ token
tutorial.cpp:26: error: variable or field ‘printIfAge’ declared void
tutorial.cpp:26: error: ‘DBClientConnection’ was not declared in this scope
tutorial.cpp:26: error: ‘c’ was not declared in this scope
tutorial.cpp:26: error: expected primary-expression before ‘int’

After reexecuting "sudo scons install" in mongodb-linux-x86_64-2.2.1 and recompile the example, none error returned.
on executing "./tutorial" the same message returned:

Fri Nov 9 09:04:12 Assertion failure p src/mongo/client/dbclientinterface.h 1105
caught assertion src/mongo/client/dbclientinterface.h:1105

Comment by Eric Milkie [ 08/Nov/12 ]

Are you sure you're using the headers from version 2.2.1? I don't see an assert on line 1105 of dbclientinterface.h; in fact there are not even executable lines there.

Generated at Thu Feb 08 03:15:00 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.