Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-73755

Potential reference to freed stack variables in AutoGetCollection::getWritableCollection

    • Type: Icon: Bug Bug
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Storage
    • Sharding EMEA
    • ALL

      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();
      

            Assignee:
            backlog-server-sharding-emea [DO NOT USE] Backlog - Sharding EMEA
            Reporter:
            kaloian.manassiev@mongodb.com Kaloian Manassiev
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: