[CXX-374] GENOID crash Created: 11/Oct/14  Updated: 13/Nov/14  Resolved: 12/Oct/14

Status: Closed
Project: C++ Driver
Component/s: BSON
Affects Version/s: legacy-1.0.0-rc0
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: traw Assignee: Unassigned
Resolution: Done Votes: 0
Labels: legacy-cxx
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

$ ./a.out
a.out: /usr/include/boost/smart_ptr/scoped_ptr.hpp:99: T* boost::scoped_ptr<T>::operator->() const [with T = mongo::AtomicWord<unsigned int>]: Assertion `px != 0' failed.
Aborted (core dumped)

stack strace

(gdb) backtrace
#0 0x00007ffff6e10bb9 in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56
#1 0x00007ffff6e13fc8 in __GI_abort () at abort.c:89
#2 0x00007ffff6e09a76 in __assert_fail_base (fmt=0x7ffff6f5b370 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=assertion@entry=0x4687fc "px != 0",
file=file@entry=0x4687d0 "/usr/include/boost/smart_ptr/scoped_ptr.hpp", line=line@entry=99,
function=function@entry=0x4688a0 <boost::scoped_ptr<mongo::AtomicWord<unsigned int> >::operator->() const::_PRETTY_FUNCTION_> "T* boost::scoped_ptr<T>::operator->() const [with T = mongo::AtomicWord<unsigned int>]") at assert.c:92
#3 0x00007ffff6e09b22 in _GI__assert_fail (assertion=0x4687fc "px != 0", file=0x4687d0 "/usr/include/boost/smart_ptr/scoped_ptr.hpp", line=99,
function=0x4688a0 <boost::scoped_ptr<mongo::AtomicWord<unsigned int> >::operator->() const::_PRETTY_FUNCTION_> "T* boost::scoped_ptr<T>::operator->() const [with T = mongo::AtomicWord<unsigned int>]") at assert.c:101
#4 0x000000000041c7c2 in operator-> (this=0x682c90 <mongo::(anonymous namespace)::counter>) at /usr/include/boost/smart_ptr/scoped_ptr.hpp:99
#5 mongo::OID::Increment::next () at src/mongo/bson/oid.cpp:53
#6 0x0https://jira.mongodb.org/browse/CXX#tab-000000000041cbbd in mongo::OID::init (this=0x7fffffffdc00) at src/mongo/bson/oid.cpp:129
#7 0x000000000040ba84 in mongo::OID::gen() ()
#8 0x000000000040c0de in mongo::BSONObjBuilder::genOID() ()
#9 0x000000000040c2ff in mongo::BSONObjBuilder::operator<<(mongo::GENOIDLabeler) ()
#10 0x000000000040b313 in main ()



 Comments   
Comment by traw [ 13/Oct/14 ]

Thanks will try and let you know

Comment by Andrew Morrow (Inactive) [ 12/Oct/14 ]

Yes, you must call the client initialize function to use the BSON library.

Comment by traw [ 12/Oct/14 ]

Main hint in error "Assertion `px != 0' failed."

Comment by traw [ 12/Oct/14 ]

NO i did not, But I was just working with BSON(), Do i need to call mongo::client::initialize() for that as well

My code:

int main(int argc, char **argv)
{
BSONObjBuilder bObj;
bObj.genOID();
bObj << "name" << "bjarne" << "lang" << "C++" ;
cout << bObj.obj().jsonString() << "\n";
return 0;
}

Comment by Andrew Morrow (Inactive) [ 11/Oct/14 ]

Have you called mongo::client::initialize() from mongo/client/init.h? You must do so before using the driver.

Generated at Wed Feb 07 21:59:01 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.