[SERVER-34765] The onCommit handler in IndexBuildBlock::init() should capture pointers by value Created: 01/May/18  Updated: 29/Oct/23  Resolved: 02/May/18

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

Type: Bug Priority: Major - P3
Reporter: Louis Williams Assignee: Louis Williams
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
Duplicate
Backwards Compatibility: Fully Compatible
Operating System: ALL
Sprint: Storage NYC 2018-05-07
Participants:
Linked BF Score: 56

 Description   

This following code captures the this pointer by reference. When the onCommit handler is run, the class has already been destructed and the pointer's value has changed. _opCtx, _entry, and _collection should be captured by value.

        _opCtx->recoveryUnit()->onCommit([&] {
            // This will prevent the unfinished index from being visible on index iterators.
            auto minVisible =
                repl::ReplicationCoordinator::get(_opCtx)->getMinimumVisibleSnapshot(_opCtx);
            _entry->setMinimumVisibleSnapshot(minVisible);
            _collection->setMinimumVisibleSnapshot(minVisible);
        });



 Comments   
Comment by Githook User [ 02/May/18 ]

Author:

{'email': 'louis.williams@mongodb.com', 'name': 'Louis Williams', 'username': 'louiswilliams'}

Message: SERVER-34765 The onCommit handler in IndexBuildBlock::init should capture pointers by value
Branch: master
https://github.com/mongodb/mongo/commit/d959bf7ab3b27ccff27205846604b8706b6c9ab4

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