[CXX-458] Crashed caused by genOID Created: 05/Jan/15  Updated: 06/Jan/15  Resolved: 06/Jan/15

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

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

Attachments: File core.31919     HTML File test     File test.cpp    

 Description   

Centos 7.0 64bit
gcc 4.8.2
mongoDB: 2.6.6
boost: 1.57

test: /usr/local/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)



 Comments   
Comment by tianchaohaohan [ 06/Jan/15 ]

Create a new dev machine with centos 7 64bit. gcc 4.8.2, boost 1.56. mongo driver build with --c++11 flag. No crash happened.

Comment by Andrew Morrow (Inactive) [ 05/Jan/15 ]

Hi -

That crash looks pretty weird. A few comments:

  • You are compiling your application in C++11 mode, but you have not compiled the driver in C++11 mode. Pass the --c++11 flag to the SCons build to get a C++11 version of the driver.
  • You appear to be using the system build of boost. Note that this boost is almost certainly not built with --std=c++11, and as far as I know boost does not guarantee ABI compatibility between C++03 and C++\11 builds. You may need to build a custom version of boost if you intend to use it in C++11 app. Or, you may find that it just works. But you should be aware that it is a risk.
  • You are building mongoclient as a shared library, and linking against it as such, which means your app will have an (indirect) runtime link dependency on the dynamic version of libstdc++. The same is likely true of the boost libraries you are linking against. However, you are compiling your application to use libstdc++ statically. This may not be what you intend. If you are trying for a fully static link, you will need to ensure that your boost install offers archive versions of the library, and request static links of all of the libraries by passing -Wl,-static <lib1> ... <libN> on the link line for your application.

Also, in general, rather than opening tickets, you might try emailing the mongodb-users group (https://groups.google.com/forum/#!forum/mongodb-user) with questions. We will work with you there to determine whether the issue is a real bug and then we can open JIRA issues as needed.

Hope this helps.

Thanks,
Andrew

Comment by tianchaohaohan [ 05/Jan/15 ]

Another crash happened after enable the call to mongo::client::initialize, here is the dump details:
(gdb) bt
#0 0x0000000000498059 in __libc_csu_init ()
#1 0x00007fff5f2c1cd0 in ?? ()
#2 0x000000000043b3c6 in mongo::client::Options::~Options (this=0xf00000000, __in_chrg=<optimized out>) at /usr/include/mongo/client/options.h:32
#3 0x00000000006bbd08 in ?? ()
#4 0x000000000049805d in __libc_csu_init ()
#5 0x00007fe5204abaf5 in __libc_start_main () from /lib64/libc.so.6
#6 0x00000000004393b5 in _start ()

binary and core dump files are attached

compile options for mongo c++ driver: scons --ssl --sharedclient install

compile options for test binary:
g++ test.cpp -o test -lmongoclient -lboost_system -lboost_thread -lboost_filesystem -lboost_program_options -lboost_regex -std=c++11 -static-libstdc++ -g

Comment by Andrew Morrow (Inactive) [ 05/Jan/15 ]

Hi -

You must call mongo::client::initialize before using any functions of the driver. Your attached test code has such a call, but it is commented out on line 32. I can reproduce your crash when running the code as written, but when I re-enable the call to mongo::client::initialize the code works correctly.

Please let me know if re-enabling the call to initialize resolves this issue for you.

Thanks,
Andrew

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