payload: {"push_id":4260786178,"size":1,"distinct_size":1,"ref":"refs/heads/feature/rework-class-hierarchy","head":"fa0af4fe0a6b9a276a5f3472b0a17ebd36b09246","before":"09b38af48b9257656f5574dd11424283c903aaf8","commits":[{"sha":"fa0af4fe0a6b9a276a5f3472b0a17ebd36b09246","author":{"name":"Jonas Schäfer","email":"042ef097061e544d2ac79d86fe4ec8027f370d56@sotecware.net"},"message":"Hide MDB*Transaction behind a unique_ptr front\n\nThis is to prevent the issue with Object Slicing. With the previous\nsolution (where MDB*Transaction are normal objects), consider the\nfollowing code:\n\n    MDBRWTransaction txn = env.getRWTransaction();\n\n    //! Invalid: We explicitly break this move because it would be\n    //! unsafe:\n    // MDBROTransaction ro_txn(std::move(txn));\n\n    //! Valid, RW inherits from RO now, so we can bind an RO\n    //! reference to an RW transaction.\n    MDBROTransaction &ro_txn = txn;\n\n    //! Dangerous!!\n    MDBROTransaction ro_txn2(std::move(ro_txn));\n\nThe last move there breaks the semantics of the RW transaction which\nis bound to the reference ro_txn. It looses its RW cursors, which\nremain partly inside the txn instance. All kinds of weird and bad\nthings can happen here. For instance, the ro_txn2 would go out of\nscope before the txn, calling the destructor MDBROTransaction\ndestructor (which defaults to commit instead of abort!) and only\nfreeing parts of the cursors. Only then the MDBRWTransaction\ndestructor is called, which will free the cursors which belong to\nthe RW transaction which has already been committed.\n\nThe only safe way to prevent Object Slicing in this scenario I\ncould come up with is to disallow moves of the objects altogether\nand instead use unique_ptr as front for them. This also removes\nan additional dynamic allocation per RW transaction (for the\ncursor vector), since the address of that vector is now constant\nover the lifetime of the transaction without indirection.","distinct":true,"url":"https://api.github.com/repos/horazont/lmdb-safe/commits/fa0af4fe0a6b9a276a5f3472b0a17ebd36b09246"}]}
other: {"actor":{"display_login":"horazont"}}