Operational Defect Database

BugZero found this defect 2495 days ago.

MongoDB | 377341

[SERVER-28958] Windows --dbg=on --opt=off build of mongod does not start

Last update date:

10/30/2023

Affected products:

MongoDB Server

Affected releases:

3.5.7

Fixed releases:

3.5.7

Description:

Info

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.

Top User Comments

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.

Additional Resources / Links

Share:

BugZero Risk Score

Coming soon

Status

Closed

Have you been affected by this bug?

cost-cta-background

Do you know how much operational outages are costing you?

Understand the cost to your business and how BugZero can help you reduce those costs.

Discussion

Login to read and write comments.

Have you ever...

had your data corrupted from a

VMware

bug?

Search:

...