[SERVER-73755] Potential reference to freed stack variables in AutoGetCollection::getWritableCollection Created: 08/Feb/23  Updated: 04/Jul/23  Resolved: 04/Jul/23

Status: Closed
Project: Core Server
Component/s: Storage
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Kaloian Manassiev Assignee: [DO NOT USE] Backlog - Sharding EMEA
Resolution: Duplicate Votes: 0
Labels: PM-2144-StorEx-Cleanup
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
duplicates SERVER-75157 Complete TODO listed in SERVER-73766 Blocked
Assigned Teams:
Sharding EMEA
Operating System: ALL
Participants:

 Description   

The AutoGetCollection utility has a very tightly coupled interdependency with CollectionWriter, in an attempt to make the committed catalog changes get reflected on an already instantiated stack object (introduced under SERVER-52877). Specifically, it stores a reference to the _coll member into a commit/rollback handler.

This requires that the WUOW's lifetime must always be subordinate to the AutoGetCollection's, which is not guaranteed to be the case with transactions. Therefore this pattern is very error-prone and can only possibly work in a very limited set of use cases.

There is a large number of users of the following pattern in order to work around the constness of some methods on Collection:

AutoGetCollection coll(...);
WUOW();
CollectionPtr writableCollection = CollectionWriter(..., coll);
writableCollection->invokeSomeDDLMethod();
WUOW::commit();


Generated at Thu Feb 08 06:25:32 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.