Commit 53a92962 authored by Georgios Bitzes's avatar Georgios Bitzes

FUSEX: Prevent double-unlock of md objects in EosFuse::link

WARNING: ThreadSanitizer: unlock of an unlocked mutex (or by a wrong thread) (pid=18781)
    #0 pthread_mutex_unlock <null> (libtsan.so.0+0x00000003b79b)
    #1 XrdSysMutex::UnLock() /usr/include/xrootd/XrdSys/XrdSysPthread.hh:151 (eosxd+0x000000607851)
    #2 XrdSysMutexHelper::UnLock() /usr/include/xrootd/XrdSys/XrdSysPthread.hh:201 (eosxd+0x000000607851)
    #3 XrdSysMutexHelper::~XrdSysMutexHelper() /usr/include/xrootd/XrdSys/XrdSysPthread.hh:212 (eosxd+0x000000607851)
    #4 EosFuse::link(fuse_req*, unsigned long, unsigned long, char const*) /afs/cern.ch/user/g/gbitzes/dev/eos-dev/fusex/eosfuse.cc:4612 (eosxd+0x000000607851)
    #5 <null> <null> (libfuse.so.2+0x0000000167e2)

  Location is heap block of size 768 at 0x7b58000e9700 allocated by thread T27:
    #0 operator new(unsigned long) <null> (libtsan.so.0+0x00000006f766)
    #1 __gnu_cxx::new_allocator<std::_Sp_counted_ptr_inplace<metad::mdx, std::allocator<metad::mdx>, (__gnu_cxx::_Lock_policy)2> >::allocate(unsigned long, void const*) /usr/include/c++/7/ext/new_allocator.h:111 (eosxd+0x000000681ab4)
    #2 std::allocator_traits<std::allocator<std::_Sp_counted_ptr_inplace<metad::mdx, std::allocator<metad::mdx>, (__gnu_cxx::_Lock_policy)2> > >::allocate(std::allocator<std::_Sp_counted_ptr_inplace<metad::mdx, std::allocator<metad::mdx>, (__gnu_cxx::_Lock_policy)2> >&, unsigned long) /usr/include/c++/7/bits/alloc_traits.h:436 (eosxd+0x000000681ab4)
    #3 std::__allocated_ptr<std::allocator<std::_Sp_counted_ptr_inplace<metad::mdx, std::allocator<metad::mdx>, (__gnu_cxx::_Lock_policy)2> > > std::__allocate_guarded<std::allocator<std::_Sp_counted_ptr_inplace<metad::mdx, std::allocator<metad::mdx>, (__gnu_cxx::_Lock_policy)2> > >(std::allocator<std::_Sp_counted_ptr_inplace<metad::mdx, std::allocator<metad::mdx>, (__gnu_cxx::_Lock_policy)2> >&) /usr/include/c++/7/bits/allocated_ptr.h:104 (eosxd+0x000000681ab4)
    #4 std::__shared_count<(__gnu_cxx::_Lock_policy)2>::__shared_count<metad::mdx, std::allocator<metad::mdx>>(std::_Sp_make_shared_tag, metad::mdx*, std::allocator<metad::mdx> const&) /usr/include/c++/7/bits/shared_ptr_base.h:635 (eosxd+0x000000681ab4)
    #5 std::__shared_ptr<metad::mdx, (__gnu_cxx::_Lock_policy)2>::__shared_ptr<std::allocator<metad::mdx>>(std::_Sp_make_shared_tag, std::allocator<metad::mdx> const&) /usr/include/c++/7/bits/shared_ptr_base.h:1295 (eosxd+0x000000681ab4)
    #6 std::shared_ptr<metad::mdx>::shared_ptr<std::allocator<metad::mdx>>(std::_Sp_make_shared_tag, std::allocator<metad::mdx> const&) /usr/include/c++/7/bits/shared_ptr.h:344 (eosxd+0x000000678905)
    #7 std::shared_ptr<metad::mdx> std::allocate_shared<metad::mdx, std::allocator<metad::mdx>>(std::allocator<metad::mdx> const&) /usr/include/c++/7/bits/shared_ptr.h:691 (eosxd+0x000000678905)
    #8 std::shared_ptr<metad::mdx> std::make_shared<metad::mdx>() /usr/include/c++/7/bits/shared_ptr.h:707 (eosxd+0x000000678905)
    #9 metad::lookup(fuse_req*, unsigned long, char const*) /afs/cern.ch/user/g/gbitzes/dev/eos-dev/fusex/md/md.cc:197 (eosxd+0x000000678905)
    #10 EosFuse::link(fuse_req*, unsigned long, unsigned long, char const*) /afs/cern.ch/user/g/gbitzes/dev/eos-dev/fusex/eosfuse.cc:4610 (eosxd+0x0000006072f8)
    #11 <null> <null> (libfuse.so.2+0x0000000167e2)

  Mutex M330868715523315928 is already destroyed.

  Thread T27 (tid=19301, running) created by thread T23 at:
    #0 pthread_create <null> (libtsan.so.0+0x000000028e03)
    #1 <null> <null> (libfuse.so.2+0x000000013134)

SUMMARY: ThreadSanitizer: unlock of an unlocked mutex (or by a wrong thread) (/usr/lib64/libtsan.so.0+0x3b79b) in pthread_mutex_unlock
parent 0f26bde6
Pipeline #500492 passed with stages
in 31 minutes and 42 seconds
......@@ -4666,11 +4666,11 @@ EosFuse::link(fuse_req_t req, fuse_ino_t ino, fuse_ino_t parent,
auto sAttrMap = md->mutable_attr();
(*sAttrMap)[k_mdino] = std::to_string(tmd->md_ino());
tmd->set_nlink(nlink + 1);
tmd->Locker().UnLock();
tmLock.UnLock();
md->set_id(Instance().mds.insert(req, md, pcap->authid()));
rc = Instance().mds.add_sync(req, pmd, md, pcap->authid());
md->set_target("");
md->Locker().UnLock();
mLock.UnLock();
if (!rc) {
XrdSysMutexHelper tmLock(tmd->Locker());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment