[
https://issues.apache.org/jira/browse/THRIFT-2755?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
James E. King, III resolved THRIFT-2755.
----------------------------------------
Resolution: Fixed
Fix Version/s: 0.11.0
I believe the work done on THRIFT-3932 has resolved this issue. I used
clang-3.8 with ThreadSanitizer and I did not see this issue. There are various
other issues that it picks up, however, I have not analyzed those but they all
seem to be centered around the fact that PThreadThread's dtor calls a virtual
method. Given we're not using C++11 we cannot define the class as final
(sealed), so ThreadSanitizer must assume calling this in the dtor could lead to
unexpected behavior.
Perhaps PThreadThread dtor should not join and the caller should do that if the
caller wants it done. However for this particular issue, I am marking it fixed.
> ThreadSanitizer reports data race in ThreadManager::Impl::addWorker
> -------------------------------------------------------------------
>
> Key: THRIFT-2755
> URL: https://issues.apache.org/jira/browse/THRIFT-2755
> Project: Thrift
> Issue Type: Bug
> Components: C++ - Library
> Affects Versions: 0.9.3, 0.10.0
> Environment: Ubuntu 12.04 x86_64, clang 3.3
> Reporter: Maksim Golov
> Assignee: James E. King, III
> Fix For: 0.11.0
>
>
> ThreadSanitizer reports the following data race:
> {code}
> ==================
> WARNING: ThreadSanitizer: data race (pid=21413)
> Read of size 8 at 0x7d4c007eb0c8 by main thread (mutexes: write M250):
> #0 apache::thrift::concurrency::ThreadManager::Impl::addWorker(unsigned
> long)
> /home/golov/project/Framework/ThirdParty/Thrift/Implementation/thrift-1.0.0_dev_f459868/lib/cpp/src/thrift/concurrency/ThreadManager.cpp:363
> (exe+0x000000892e55)
> #1 apache::thrift::concurrency::SimpleThreadManager::start()
> /home/golov/project/Framework/ThirdParty/Thrift/Implementation/thrift-1.0.0_dev_f459868/lib/cpp/src/thrift/concurrency/ThreadManager.cpp:563
> (exe+0x0000008a93ad)
> #2 main /home/golov/project/Project/Main.cpp:201 (exe+0x000000758aa3)
> Previous write of size 8 at 0x7d4c007eb0c8 by thread T7 (mutexes: write
> M249):
> #0 apache::thrift::concurrency::ThreadManager::Worker::run()
> /home/golov/project/Framework/ThirdParty/Thrift/Implementation/thrift-1.0.0_dev_f459868/lib/cpp/src/thrift/concurrency/ThreadManager.cpp:251
> (exe+0x0000008ac9eb)
> #1 apache::thrift::concurrency::PthreadThread::threadMain(void*)
> /home/golov/project/Framework/ThirdParty/Thrift/Implementation/thrift-1.0.0_dev_f459868/lib/cpp/src/thrift/concurrency/PosixThreadFactory.cpp:207
> (exe+0x0000008c4e70)
> Location is heap block of size 440 at 0x7d4c007eb0c0 allocated by main
> thread:
> #0 operator new(unsigned long) ??:0 (exe+0x000000726b56)
> #1
> apache::thrift::concurrency::ThreadManager::newSimpleThreadManager(unsigned
> long, unsigned long)
> /home/golov/project/Framework/ThirdParty/Thrift/Implementation/thrift-1.0.0_dev_f459868/lib/cpp/src/thrift/concurrency/ThreadManager.cpp:579
> (exe+0x000000894db3)
> #2 main /home/golov/project/Project/Main.cpp:197 (exe+0x000000758983)
> Mutex M250 created at:
> #0 pthread_mutex_init ??:0 (exe+0x000000729e65)
> #1 apache::thrift::concurrency::Mutex::DEFAULT_INITIALIZER(void*)
> /home/golov/project/Framework/ThirdParty/Thrift/Implementation/thrift-1.0.0_dev_f459868/lib/cpp/src/thrift/concurrency/Mutex.cpp:209
> (exe+0x0000008bf8e2)
> rc/thrift/concurrency/Mutex.cpp:122 (exe+0x0000008c2a34)
> #3 impl
> /home/golov/project/Framework/ThirdParty/Thrift/Implementation/thrift-1.0.0_dev_f459868/lib/cpp/src/thrift/concurrency/Mutex.cpp:124
> (exe+0x0000008c0390)
> #4 Mutex
> /home/golov/project/Framework/ThirdParty/Thrift/Implementation/thrift-1.0.0_dev_f459868/lib/cpp/src/thrift/concurrency/Mutex.cpp:195
> (exe+0x0000008bf5a0)
> #5 Impl
> /home/golov/project/Framework/ThirdParty/Thrift/Implementation/thrift-1.0.0_dev_f459868/lib/cpp/src/thrift/concurrency/Monitor.cpp:49
> (exe+0x0000008c4aff)
> #6 Impl
> /home/golov/project/Framework/ThirdParty/Thrift/Implementation/thrift-1.0.0_dev_f459868/lib/cpp/src/thrift/concurrency/Monitor.cpp:51
> (exe+0x0000008c34c0)
> #7 Monitor
> /home/golov/project/Framework/ThirdParty/Thrift/Implementation/thrift-1.0.0_dev_f459868/lib/cpp/src/thrift/concurrency/Monitor.cpp:187
> (exe+0x0000008c2aee)
> #8 Impl
> /home/golov/project/Framework/ThirdParty/Thrift/Implementation/thrift-1.0.0_dev_f459868/lib/cpp/src/thrift/concurrency/ThreadManager.cpp:63
> (exe+0x0000008a8ea4)
> #9 SimpleThreadManager
> /home/golov/project/Framework/ThirdParty/Thrift/Implementation/thrift-1.0.0_dev_f459868/lib/cpp/src/thrift/concurrency/ThreadManager.cpp:557
> (exe+0x0000008a8b53)
> #10 SimpleThreadManager
> /home/golov/project/Framework/ThirdParty/Thrift/Implementation/thrift-1.0.0_dev_f459868/lib/cpp/src/thrift/concurrency/ThreadManager.cpp:558
> (exe+0x000000897020)
> #11
> apache::thrift::concurrency::ThreadManager::newSimpleThreadManager(unsigned
> long, unsigned long)
> /home/golov/project/Framework/ThirdParty/Thrift/Implementation/thrift-1.0.0_dev_f459868/lib/cpp/src/thrift/concurrency/ThreadManager.cpp:579
> (exe+0x000000894df2)
> #12 main /home/golov/project/Project/Main.cpp:197 (exe+0x000000758983)
> Mutex M249 created at:
> #0 pthread_mutex_init ??:0 (exe+0x000000729e65)
> #1 apache::thrift::concurrency::Mutex::DEFAULT_INITIALIZER(void*)
> /home/golov/project/Framework/ThirdParty/Thrift/Implementation/thrift-1.0.0_dev_f459868/lib/cpp/src/thrift/concurrency/Mutex.cpp:209
> (exe+0x0000008bf8e2)
> #2 impl
> /home/golov/project/Framework/ThirdParty/Thrift/Implementation/thrift-1.0.0_dev_f459868/lib/cpp/src/thrift/concurrency/Mutex.cpp:122
> (exe+0x0000008c2a34)
> #3 impl
> /home/golov/project/Framework/ThirdParty/Thrift/Implementation/thrift-1.0.0_dev_f459868/lib/cpp/src/thrift/concurrency/Mutex.cpp:124
> (exe+0x0000008c0390)
> #4 Mutex
> /home/golov/project/Framework/ThirdParty/Thrift/Implementation/thrift-1.0.0_dev_f459868/lib/cpp/src/thrift/concurrency/Mutex.cpp:195
> (exe+0x0000008bf5a0)
> #5 Impl
> /home/golov/project/Framework/ThirdParty/Thrift/Implementation/thrift-1.0.0_dev_f459868/lib/cpp/src/thrift/concurrency/ThreadManager.cpp:63
> (exe+0x0000008a8e2e)
> #6 SimpleThreadManager
> /home/golov/project/Framework/ThirdParty/Thrift/Implementation/thrift-1.0.0_dev_f459868/lib/cpp/src/thrift/concurrency/ThreadManager.cpp:557
> (exe+0x0000008a8b53)
> #7 SimpleThreadManager
> /home/golov/project/Framework/ThirdParty/Thrift/Implementation/thrift-1.0.0_dev_f459868/lib/cpp/src/thrift/concurrency/ThreadManager.cpp:558
> (exe+0x000000897020)
> #8
> apache::thrift::concurrency::ThreadManager::newSimpleThreadManager(unsigned
> long, unsigned long)
> /home/golov/project/Framework/ThirdParty/Thrift/Implementation/thrift-1.0.0_dev_f459868/lib/cpp/src/thrift/concurrency/ThreadManager.cpp:579
> (exe+0x000000894df2)
> #9 main /home/golov/project/Project/Main.cpp:197 (exe+0x000000758983)
> Thread T7 (tid=21516, running) created by main thread at:
> #0 pthread_create ??:0 (exe+0x0000007298b2)
> #1 apache::thrift::concurrency::PthreadThread::start()
> /home/golov/project/Framework/ThirdParty/Thrift/Implementation/thrift-1.0.0_dev_f459868/lib/cpp/src/thrift/concurrency/PosixThreadFactory.cpp:146
> (exe+0x0000008c90f9)
> #2 apache::thrift::concurrency::ThreadManager::Impl::addWorker(unsigned
> long)
> /home/golov/project/Framework/ThirdParty/Thrift/Implementation/thrift-1.0.0_dev_f459868/lib/cpp/src/thrift/concurrency/ThreadManager.cpp:357
> (exe+0x000000892bb1)
> #3 apache::thrift::concurrency::SimpleThreadManager::start()
> /home/golov/project/Framework/ThirdParty/Thrift/Implementation/thrift-1.0.0_dev_f459868/lib/cpp/src/thrift/concurrency/ThreadManager.cpp:563
> (exe+0x0000008a93ad)
> #4 main /home/golov/project/Project/Main.cpp:201 (exe+0x000000758aa3)
> SUMMARY: ThreadSanitizer: data race
> /home/golov/project/Framework/ThirdParty/Thrift/Implementation/thrift-1.0.0_dev_f459868/lib/cpp/src/thrift/concurrency/ThreadManager.cpp:363
> apache::thrift::concurrency::ThreadManager::Impl::addWorker(unsigned long)
> ==================
> {code}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)