...
BugZero found this defect 2843 days ago.
It looks like the static initializer for ResourceId runs before that of StringData::ComparatorInterface and the process won't start: mongod.exe!mongo::StringData::ComparatorInterface::hash(mongo::StringData stringToHash) mongo\base\string_data_comparator_interface.h Line 98 C++ mongod.exe!mongo::ResourceId::ResourceId(mongo::ResourceType type, mongo::StringData ns) mongo\db\concurrency\lock_manager.cpp Line 1119 C++ mongod.exe!mongo::`dynamic initializer for 'resourceIdLocalDB''() mongo\db\concurrency\lock_state.cpp Line 959 C++ ucrtbased.dll!_initterm�() Unknown mongod.exe!__scrt_common_main_seh() Line 223 C++ mongod.exe!__scrt_common_main() Line 296 C++ mongod.exe!wmainCRTStartup() Line 17 C++ kernel32.dll!BaseThreadInitThunk�() Unknown ntdll.dll!RtlUserThreadStart�() Unknown This is most likely a result of the recent vtable changes.
xgen-internal-githook commented on Wed, 26 Apr 2017 14:26:30 +0000: Author: {u'username': u'kaloianm', u'name': u'Kaloian Manassiev', u'email': u'kaloian.manassiev@mongodb.com'} Message: SERVER-28958 Remove dependency of ResourceId on SimpleStringDataComparator Branch: master https://github.com/mongodb/mongo/commit/1100c4a3466ee860cdbd6ceb9d9719fe95103700 acm commented on Tue, 25 Apr 2017 19:48:06 +0000: Actually, it is ASAN that can do this, not UBSAN: https://github.com/google/sanitizers/wiki/AddressSanitizerInitializationOrderFiasco acm commented on Tue, 25 Apr 2017 15:09:11 +0000: Details on what is going wrong here: LockState.cpp defines a static const ResourceId resourceIdLocalDB. The constructor for ResourceId contains a call to SimpleStringDataComparator::kInstance.hash. The static for SimpleStringDataComparator::kInstance.hash is declared in a separate TU, simple_string_data_comparator.cpp. This is a classic initialization order fiasco, which is a form of undefined behavior. This UB was latent in the codebase; it just chose to exhibit symptoms recently. Possible remedies would include: Making either ResourceId or SimpleStringDataComparator literal types, so that the constants like resourceIdLocalDB or SimpleStringDataComparator::kInstance can be constexpr, so they get constant, rather than dynamic, initialization. Making resourceIdLocalDB and similar into functions, containing a function scoped static ResourceId, rather than a file scoped static. In general, we are far to profligate with our use of file scoped statics, and the codebase is rife with these errors. This is unfortunate, because it means that we can't actually enable the UBSAN check that would call this out for us.
Build Windows Enterprise using this command line (the library paths are relative to my development machine): buildscripts\scons.py -j 12 --dbg=on --opt=off --ssl --dynamic-windows --win-version-min=ws08r2 CPPPATH="D:/workspace/libs/snmp/include D:/workspace/libs/sasl/include D:/workspace/libs/openssl/include D:/workspace/libs/curl/include" LIBPATH="D:/workspace/libs/snmp/lib D:/workspace/libs/sasl/lib D:/workspace/libs/openssl/lib D:/workspace/libs/curl/lib" VERBOSE=false mongod.exe mongos.exe mongo.exe