"Security is a singleton class" error using c++ client code

101 views
Skip to first unread message

bhaskara

unread,
Sep 9, 2011, 2:34:53 PM9/9/11
to mongodb-user
Hi all, I'm getting the following error, when running an executable
that uses the C++ interface:

Thu Sep 8 14:48:45 warning: 2 commands with name: connPoolSync
Thu Sep 8 14:48:45 warning: 2 commands with name: connPoolStats
Thu Sep 8 14:48:45 Assertion: 10352:Security is a singleton class
0x4e6d81 0x4e3959 0x5334f6
bin/plane_tracker(_ZN5mongo11msgassertedEiPKc+0x131) [0x4e6d81]
bin/plane_tracker(_ZN5mongo8SecurityC1Ev+0x29) [0x4e3959]
bin/plane_tracker() [0x5334f6]
terminate called after throwing an instance of
'mongo::MsgAssertionException'
what(): Security is a singleton class

I haven't precisely diagnosed what's going on, but I suspect that the
problem is that I have two independent libraries, each of which are
linked against the static library libmongoclient.a. My executable
then gets both of these, leading to the singleton error. Looking at
nonce.cpp, I see that it declares an instance of the singleton object
Security at namespace scope. Could this be the cause of the problem,
and if so, how does one work around it?

I'm on Ubuntu Lucid, using 1.8.1.

Mathias Stearn

unread,
Sep 9, 2011, 4:00:18 PM9/9/11
to mongod...@googlegroups.com
I think the best option is to either use a dynamic shared libmongo or to compile your two libraries as static  libs and then link them along with a single copy of libmongo.a into your executable.

bhaskara

unread,
Sep 9, 2011, 4:04:31 PM9/9/11
to mongodb-user
I'm not very familiar with Scons. Is there a simple way to switch it
to building libmongoclient as a dynamic shared library?

Mathias Stearn

unread,
Sep 9, 2011, 4:18:05 PM9/9/11
to mongod...@googlegroups.com
--sharedclient

you can see a list of all flags with scons --help. Note that the ones after the line "Local Options", including --sharedclient are specific to the mongo build scripts are are not general scons flags
Reply all
Reply to author
Forward
0 new messages