[CXX-523] OID::gen, createIndex, needs sensible error if client::initialize is not called Created: 10/Feb/15  Updated: 22/Feb/15  Resolved: 22/Feb/15

Status: Closed
Project: C++ Driver
Component/s: API
Affects Version/s: legacy-1.0.0-rc4, legacy-1.0.0
Fix Version/s: None

Type: Improvement Priority: Minor - P4
Reporter: Stuart Reynolds Assignee: Andrew Morrow (Inactive)
Resolution: Done Votes: 0
Labels: legacy-cxx
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

#include <mongo/client/dbclient.h>
#include <mongo/bson/oid.h>

int main( int argc, char const* argv[] ){
mongo::OID::gen();
}

Yields:

/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.

I can create a client connection and createIndex. The library then fails in the same mysterious way.

client::initialize() was missed. Library should error out sensibly where initialize is required and forgotten.



 Comments   
Comment by Andrew Morrow (Inactive) [ 18/Feb/15 ]

stuartreynolds -

Thanks for the report. For us to do this meaningfully, we would need to instrument every path into the driver with the appropriate checks for initialization, and those checks would be pure overhead in all valid runtime paths into the driver where initialize had already been called. It is well documented that you must call the initialize functions before using the driver, and all of our example code does so. Additionally many entry points that require prior initialization do not have an error return path, so we would need to crash with an assertion failure anyway, just with a different message.

Our assessment is that we do not believe that this change offers enough benefit to justify the additional complexity.

Thanks,
Andrew

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