]> git.apps.os.sepia.ceph.com Git - ceph.git/commit
SharedPtrRegistry: get_next must not delete while holding the lock 545/head
authorLoic Dachary <loic@dachary.org>
Tue, 27 Aug 2013 14:09:17 +0000 (16:09 +0200)
committerLoic Dachary <loic@dachary.org>
Tue, 27 Aug 2013 14:09:17 +0000 (16:09 +0200)
commitea2fc85e091683ced062594ad25fa569e5c1bbd7
treeaca4fe2df2652f51f05bee4db6f86bdaa61cc4dd
parentaf5281e0f672554a322fef826d2229f563ae8577
SharedPtrRegistry: get_next must not delete while holding the lock

    bool get_next(const K &key, pair<K, VPtr> *next)

may indirectly delete the object pointed by next->second when
doing :

    *next = make_pair(i->first, next_val);

and it will deadlock (EDEADLK) when

    void operator()(V *to_remove) {
      {
Mutex::Locker l(parent->lock);

tries to acquire the lock because it is already held. The
Mutex::Locker is isolated in a block and the *next* parameter is set
outside of the block.

A test case demonstrating the problem is added to test_sharedptr_registry.cc

http://tracker.ceph.com/issues/6117 fixes #6117

Signed-off-by: Loic Dachary <loic@dachary.org>
src/common/sharedptr_registry.hpp
src/test/common/test_sharedptr_registry.cc