Commit c91f33ac authored by Georgios Bitzes's avatar Georgios Bitzes

FUSEX: Add missing write lock when calling set_fullpath on md object

WARNING: ThreadSanitizer: data race (pid=23527) Write of size 1 at 0x7b1800024c00 by thread T29 (mutexes: write M2928): #0 std::char_traits<char>::assign(char&, char const&) /usr/include/c++/7/bits/char_traits.h:285 (eosxd+0x0000006788d8) #1 std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_set_length(unsigned long) /usr/include/c++/7/bits/basic_string.h:206 (eosxd+0x0000006788d8) #2 std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::clear() /usr/include/c++/7/bits/basic_string.h:1005 (eosxd+0x0000006788d8) #3 std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::operator=(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&&) /usr/include/c++/7/bits/basic_string.h:767 (eosxd+0x0000006788d8) #4 google::protobuf::internal::ArenaStringPtr::SetNoArena(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&&) /usr/include/google/protobuf/arenastring.h:218 (eosxd+0x0000006788d8) #5 eos::fusex::md::set_fullpath(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&&) /home/gbitzes/eos-dev-tsan/fusex/fusex.pb.h:4005 (eosxd+0x0000006788d8) #6 metad::lookup(fuse_req*, unsigned long, char const*) /afs/cern.ch/user/g/gbitzes/dev/eos-dev/fusex/md/md.cc:226 (eosxd+0x0000006788d8) #7 EosFuse::rename(fuse_req*, unsigned long, char const*, unsigned long, char const*) /afs/cern.ch/user/g/gbitzes/dev/eos-dev/fusex/eosfuse.cc:2928 (eosxd+0x0000005ec1ea) #8 <null> <null> (libfuse.so.2+0x0000000167e2) Previous read of size 8 at 0x7b1800024c00 by thread T19 (mutexes: write M685808661155788760): #0 memcpy <null> (libtsan.so.0+0x000000030101) #1 google::protobuf::io::CodedOutputStream::WriteRawToArray(void const*, int, unsigned char*) <null> (libprotobuf.so.13+0x0000000e96b4) #2 google::protobuf::MessageLite::AppendPartialToString(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*) const <null> (libprotobuf.so.13+0x0000000e4f3b) #3 void std::__invoke_impl<void, void (metad::*)(ThreadAssistant&), metad*, std::reference_wrapper<ThreadAssistant> >(std::__invoke_memfun_deref, void (metad::*&&)(ThreadAssistant&), metad*&&, std::reference_wrapper<ThreadAssistant>&&) /usr/include/c++/7/bits/invoke.h:73 (eosxd+0x00000060db40) #4 std::__invoke_result<void (metad::*)(ThreadAssistant&), metad*, std::reference_wrapper<ThreadAssistant> >::type std::__invoke<void (metad::*)(ThreadAssistant&), metad*, std::reference_wrapper<ThreadAssistant> >(void (metad::*&&)(ThreadAssistant&), metad*&&, std::reference_wrapper<ThreadAssistant>&&) /usr/include/c++/7/bits/invoke.h:95 (eosxd+0x00000060db40) #5 decltype (__invoke((_S_declval<0ul>)(), (_S_declval<1ul>)(), (_S_declval<2ul>)())) std::thread::_Invoker<std::tuple<void (metad::*)(ThreadAssistant&), metad*, std::reference_wrapper<ThreadAssistant> > >::_M_invoke<0ul, 1ul, 2ul>(std::_Index_tuple<0ul, 1ul, 2ul>) /usr/include/c++/7/thread:234 (eosxd+0x00000060db40) #6 std::thread::_Invoker<std::tuple<void (metad::*)(ThreadAssistant&), metad*, std::reference_wrapper<ThreadAssistant> > >::operator()() /usr/include/c++/7/thread:243 (eosxd+0x00000060db40) #7 std::thread::_State_impl<std::thread::_Invoker<std::tuple<void (metad::*)(ThreadAssistant&), metad*, std::reference_wrapper<ThreadAssistant> > > >::_M_run() /usr/include/c++/7/thread:186 (eosxd+0x00000060db40) #8 <null> <null> (libstdc++.so.6+0x0000000bc53e) Location is heap block of size 91 at 0x7b1800024c00 allocated by thread T36: #0 operator new(unsigned long) <null> (libtsan.so.0+0x00000006f766) #1 std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_mutate(unsigned long, unsigned long, char const*, unsigned long) <null> (libstdc++.so.6+0x000000126209) #2 <null> <null> (libfuse.so.2+0x0000000151a6) Mutex M2928 (0x7b1000019d08) created at: #0 pthread_rwlock_timedwrlock <null> (libtsan.so.0+0x00000002a8d0) #1 bool std::shared_timed_mutex::try_lock_until<std::chrono::duration<long, std::ratio<1l, 1000000000l> > >(std::chrono::time_point<std::chrono::_V2::system_clock, std::chrono::duration<long, std::ratio<1l, 1000000000l> > > const&) /usr/include/c++/7/shared_mutex:417 (libeosCommon.so.4+0x00000008b936) #2 bool std::shared_timed_mutex::try_lock_for<long, std::ratio<1l, 1000000000l> >(std::chrono::duration<long, std::ratio<1l, 1000000000l> > const&) /usr/include/c++/7/shared_mutex:384 (libeosCommon.so.4+0x00000008b936) #3 eos::common::SharedMutex::TimedWrLock(unsigned long) /afs/cern.ch/user/g/gbitzes/dev/eos-dev/common/SharedMutex.cc:88 (libeosCommon.so.4+0x00000008b936) #4 eos::common::RWMutex::LockWrite() /afs/cern.ch/user/g/gbitzes/dev/eos-dev/common/RWMutex.cc:360 (libeosCommon.so.4+0x0000000854b1) #5 Track::Attach(unsigned long long, bool) /afs/cern.ch/user/g/gbitzes/dev/eos-dev/fusex/misc/Track.hh:85 (eosxd+0x0000006143ea) #6 Track::Monitor::Monitor(char const*, Track&, unsigned long long, bool, bool) /afs/cern.ch/user/g/gbitzes/dev/eos-dev/fusex/misc/Track.hh:109 (eosxd+0x0000006143ea) #7 EosFuse::mkdir(fuse_req*, unsigned long, char const*, unsigned int) /afs/cern.ch/user/g/gbitzes/dev/eos-dev/fusex/eosfuse.cc:2421 (eosxd+0x000000600473) #8 <null> <null> (libfuse.so.2+0x0000000167e2) Mutex M685808661155788760 is already destroyed. Thread T29 (tid=24008, running) created by thread T28 at: #0 pthread_create <null> (libtsan.so.0+0x000000028e03) #1 <null> <null> (libfuse.so.2+0x000000013134) Thread T19 (tid=23559, running) created by main thread at: #0 pthread_create <null> (libtsan.so.0+0x000000028e03) #1 std::thread::_M_start_thread(std::unique_ptr<std::thread::_State, std::default_delete<std::thread::_State> >, void (*)()) <null> (libstdc++.so.6+0x0000000bc824) #2 EosFuse::run(int, char**, void*) /afs/cern.ch/user/g/gbitzes/dev/eos-dev/fusex/eosfuse.cc:1218 (eosxd+0x0000005e5bfa) #3 main /afs/cern.ch/user/g/gbitzes/dev/eos-dev/fusex/main.cc:30 (eosxd+0x0000004e18d8) Thread T36 (tid=24015, running) created by thread T35 at: #0 pthread_create <null> (libtsan.so.0+0x000000028e03) #1 <null> <null> (libfuse.so.2+0x000000013134) SUMMARY: ThreadSanitizer: data race /usr/include/c++/7/bits/char_traits.h:285 in std::char_traits<char>::assign(char&, char const&)
parent 53a92962
Pipeline #500508 passed with stages
in 26 minutes 48 seconds
......@@ -223,7 +223,9 @@ metad::lookup(fuse_req_t req, fuse_ino_t parent, const char* name)
// --------------------------------------------------
pmd->Locker().UnLock();
md = get(req, inode, "", false, pmd, name);
md->Locker().Lock();
md->set_fullpath(pmd->fullpath() + name);
md->Locker().UnLock();
pmd->Locker().Lock();
} else {
// --------------------------------------------------
......
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