[SERVER-22681] Collection::infoCache invoked through nullptr Created: 17/Feb/16  Updated: 16/Mar/16  Resolved: 29/Feb/16

Status: Closed
Project: Core Server
Component/s: Internal Code
Affects Version/s: None
Fix Version/s: 3.3.3

Type: Bug Priority: Major - P3
Reporter: Andrew Morrow (Inactive) Assignee: Max Hirschhorn
Resolution: Done Votes: 0
Labels: undefined-sanitizer
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Backwards Compatibility: Fully Compatible
Operating System: ALL
Steps To Reproduce:

Add an invariant(collection) before the call to collection->infoCache() in the above files, run jscore.

Sprint: Query 11 (03/14/16)
Participants:

 Description   

There are at least two situations where the Collection::infoCache method is called on a nullptr Collection object:

https://github.com/mongodb/mongo/blob/ff8ca92aafd08c17f93bf00bf7aeaac79643ad02/src/mongo/db/commands/write_commands/batch_executor.cpp#L1354

https://github.com/mongodb/mongo/blob/ff8ca92aafd08c17f93bf00bf7aeaac79643ad02/src/mongo/db/instance.cpp#L862

Adding a

invariant(collection)

will cause invariant failures at these locations when running the 'core' suite. Other locations that assume that the Collection pointer is valid before calling Collection::infoCache should probably also be checked.



 Comments   
Comment by Githook User [ 29/Feb/16 ]

Author:

{u'username': u'visemet', u'name': u'Max Hirschhorn', u'email': u'max.hirschhorn@mongodb.com'}

Message: SERVER-22681 Avoid calling infoCache() when collection doesn't exist.
Branch: master
https://github.com/mongodb/mongo/commit/3f2d923f88e2e6f70f25a8b161b09bc2bb227e10

Comment by Andrew Morrow (Inactive) [ 17/Feb/16 ]

Another instance of this:

https://github.com/mongodb/mongo/blob/3b90410d75079ea80800eadc65bf599d9d525817/src/mongo/db/commands/distinct.cpp#L234

Generated at Thu Feb 08 04:01:09 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.