[llvm-bugs] [Bug 32649] New: std::__1::binomial_distribution is not thread safe
via llvm-bugs
llvm-bugs at lists.llvm.org
Thu Apr 13 00:41:10 PDT 2017
https://bugs.llvm.org/show_bug.cgi?id=32649
Bug ID: 32649
Summary: std::__1::binomial_distribution is not thread safe
Product: libc++
Version: 4.0
Hardware: PC
OS: MacOS X
Status: NEW
Severity: enhancement
Priority: P
Component: All Bugs
Assignee: unassignedclangbugs at nondot.org
Reporter: vincent.lebourlot at starqube.com
CC: llvm-bugs at lists.llvm.org, mclow.lists at gmail.com
On mac, std::binomial_distribution calls POSIX version of lgamma which is not
thread safe (see notes on http://en.cppreference.com/w/cpp/numeric/math/lgamma)
causing multiple threads to use global variables 'signgam' (libsystem_m.dylib).
==================
WARNING: ThreadSanitizer: data race (pid=64621)
Write of size 1 at 0x7fffa6519248 by thread T89:
#0 lgamma <null> (libclang_rt.tsan_osx_dynamic.dylib:x86_64+0x16e5b)
#1 std::__1::binomial_distribution<unsigned
int>::param_type::param_type(unsigned int, double) <null>
(TestHisto:x86_64+0x1000418a4)
#2 std::__1::binomial_distribution<unsigned
int>::param_type::param_type(unsigned int, double) <null>
(TestHisto:x86_64+0x100041738)
#3 StarQube::RandomString<StarQube::String>::RandomString(bool) <null>
(TestHisto:x86_64+0x10004145d)
#4 StarQube::Random<StarQube::String>::Random(bool) <null>
(TestHisto:x86_64+0x100040f48)
#5 StarQube::Random<StarQube::String>::Random(bool) <null>
(TestHisto:x86_64+0x100034b1e)
#6 StarQube::createValues(StarQube::ValueType, unsigned long,
std::__1::mersenne_twister_engine<unsigned long long, 64ul, 312ul, 156ul, 31ul,
13043109905998158313ull, 29ul, 6148914691236517205ull, 17ul,
8202884508482404352ull, 37ul, 18444473444759240704ull, 43ul,
6364136223846793005ull>&) <null> (TestHisto:x86_64+0x100009e95)
#7 TestHisto::checkDataCross(StarQube::QuantClient const&, StarQube::String
const&, StarQube::Freq, StarQube::ValueType, StarQube::ValueType,
StarQube::ValueType, StarQube::ValueType, unsigned long, unsigned long,
unsigned long) <null> (TestHisto:x86_64+0x100008b4a)
#8 TestHisto::testHisto(StarQube::QuantClient const&, StarQube::String
const&)::$_1::operator()() const <null> (TestHisto:x86_64+0x10005ffa3)
#9 void
std::__1::__invoke_void_return_wrapper<void>::__call<TestHisto::testHisto(StarQube::QuantClient
const&, StarQube::String
const&)::$_1&>(TestHisto::testHisto(StarQube::QuantClient const&,
StarQube::String const&)::$_1&&&) <null> (TestHisto:x86_64+0x10005fdb0)
#10 std::__1::__function::__func<TestHisto::testHisto(StarQube::QuantClient
const&, StarQube::String const&)::$_1,
std::__1::allocator<TestHisto::testHisto(StarQube::QuantClient const&,
StarQube::String const&)::$_1>, void ()>::operator()() <null>
(TestHisto:x86_64+0x10005f96c)
#11 std::__1::function<void ()>::operator()() const <null>
(TestHisto:x86_64+0x1000441cc)
#12 StarQube::Thread::run(std::__1::vector<std::__1::function<void ()>,
std::__1::allocator<std::__1::function<void ()> > > const&, unsigned
long)::$_0::operator()() const <null> (TestHisto:x86_64+0x100e18280)
#13 void*
std::__1::__thread_proxy<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct,
std::__1::default_delete<std::__1::__thread_struct> >,
StarQube::Thread::run(std::__1::vector<std::__1::function<void ()>,
std::__1::allocator<std::__1::function<void ()> > > const&, unsigned
long)::$_0> >(void*) <null> (TestHisto:x86_64+0x100e19b60)
Previous write of size 1 at 0x7fffa6519248 by thread T95:
#0 lgamma <null> (libclang_rt.tsan_osx_dynamic.dylib:x86_64+0x16e5b)
#1 std::__1::binomial_distribution<unsigned
int>::param_type::param_type(unsigned int, double) <null>
(TestHisto:x86_64+0x1000418a4)
#2 std::__1::binomial_distribution<unsigned
int>::param_type::param_type(unsigned int, double) <null>
(TestHisto:x86_64+0x100041738)
#3 StarQube::RandomString<StarQube::String>::RandomString(bool) <null>
(TestHisto:x86_64+0x10004145d)
#4 StarQube::Random<StarQube::String>::Random(bool) <null>
(TestHisto:x86_64+0x100040f48)
#5 StarQube::Random<StarQube::String>::Random(bool) <null>
(TestHisto:x86_64+0x100034b1e)
#6 StarQube::createValues(StarQube::ValueType, unsigned long,
std::__1::mersenne_twister_engine<unsigned long long, 64ul, 312ul, 156ul, 31ul,
13043109905998158313ull, 29ul, 6148914691236517205ull, 17ul,
8202884508482404352ull, 37ul, 18444473444759240704ull, 43ul,
6364136223846793005ull>&) <null> (TestHisto:x86_64+0x100009e95)
#7 TestHisto::checkDataCross(StarQube::QuantClient const&, StarQube::String
const&, StarQube::Freq, StarQube::ValueType, StarQube::ValueType,
StarQube::ValueType, StarQube::ValueType, unsigned long, unsigned long,
unsigned long) <null> (TestHisto:x86_64+0x100008b4a)
#8 TestHisto::testHisto(StarQube::QuantClient const&, StarQube::String
const&)::$_1::operator()() const <null> (TestHisto:x86_64+0x10005ffa3)
#9 void
std::__1::__invoke_void_return_wrapper<void>::__call<TestHisto::testHisto(StarQube::QuantClient
const&, StarQube::String
const&)::$_1&>(TestHisto::testHisto(StarQube::QuantClient const&,
StarQube::String const&)::$_1&&&) <null> (TestHisto:x86_64+0x10005fdb0)
#10 std::__1::__function::__func<TestHisto::testHisto(StarQube::QuantClient
const&, StarQube::String const&)::$_1,
std::__1::allocator<TestHisto::testHisto(StarQube::QuantClient const&,
StarQube::String const&)::$_1>, void ()>::operator()() <null>
(TestHisto:x86_64+0x10005f96c)
#11 std::__1::function<void ()>::operator()() const <null>
(TestHisto:x86_64+0x1000441cc)
#12 StarQube::Thread::run(std::__1::vector<std::__1::function<void ()>,
std::__1::allocator<std::__1::function<void ()> > > const&, unsigned
long)::$_0::operator()() const <null> (TestHisto:x86_64+0x100e18280)
#13 void*
std::__1::__thread_proxy<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct,
std::__1::default_delete<std::__1::__thread_struct> >,
StarQube::Thread::run(std::__1::vector<std::__1::function<void ()>,
std::__1::allocator<std::__1::function<void ()> > > const&, unsigned
long)::$_0> >(void*) <null> (TestHisto:x86_64+0x100e19b60)
Location is global 'signgam' at 0x7fffa6519248
(libsystem_m.dylib+0x000008d0f248)
Thread T89 (tid=15957282, running) created by main thread at:
#0 pthread_create <null> (libclang_rt.tsan_osx_dynamic.dylib:x86_64+0x7391)
#1
std::__1::thread::thread<StarQube::Thread::run(std::__1::vector<std::__1::function<void
()>, std::__1::allocator<std::__1::function<void ()> > > const&, unsigned
long)::$_0&,
void>(StarQube::Thread::run(std::__1::vector<std::__1::function<void ()>,
std::__1::allocator<std::__1::function<void ()> > > const&, unsigned
long)::$_0&&&) <null> (TestHisto:x86_64+0x100e19156)
#2
std::__1::thread::thread<StarQube::Thread::run(std::__1::vector<std::__1::function<void
()>, std::__1::allocator<std::__1::function<void ()> > > const&, unsigned
long)::$_0&,
void>(StarQube::Thread::run(std::__1::vector<std::__1::function<void ()>,
std::__1::allocator<std::__1::function<void ()> > > const&, unsigned
long)::$_0&&&) <null> (TestHisto:x86_64+0x100e18848)
#3
StarQube::Thread::Thread<StarQube::Thread::run(std::__1::vector<std::__1::function<void
()>, std::__1::allocator<std::__1::function<void ()> > > const&, unsigned
long)::$_0&>(StarQube::String const&,
StarQube::Thread::run(std::__1::vector<std::__1::function<void ()>,
std::__1::allocator<std::__1::function<void ()> > > const&, unsigned
long)::$_0&&&) <null> (TestHisto:x86_64+0x100e1845a)
#4
StarQube::Thread::Thread<StarQube::Thread::run(std::__1::vector<std::__1::function<void
()>, std::__1::allocator<std::__1::function<void ()> > > const&, unsigned
long)::$_0&>(StarQube::String const&,
StarQube::Thread::run(std::__1::vector<std::__1::function<void ()>,
std::__1::allocator<std::__1::function<void ()> > > const&, unsigned
long)::$_0&&&) <null> (TestHisto:x86_64+0x100e17dd8)
#5 StarQube::Thread::run(std::__1::vector<std::__1::function<void ()>,
std::__1::allocator<std::__1::function<void ()> > > const&, unsigned long)
<null> (TestHisto:x86_64+0x100e1779d)
#6 TestHisto::testHisto(StarQube::QuantClient const&, StarQube::String
const&) <null> (TestHisto:x86_64+0x100017839)
#7 TestHisto::main() <null> (TestHisto:x86_64+0x100030cb1)
#8 StarQube::runSuite(char const*, void (*)(), bool) <null>
(TestHisto:x86_64+0x100032414)
#9 main <null> (TestHisto:x86_64+0x10003219c)
Thread T95 (tid=15957288, running) created by main thread at:
#0 pthread_create <null> (libclang_rt.tsan_osx_dynamic.dylib:x86_64+0x7391)
#1
std::__1::thread::thread<StarQube::Thread::run(std::__1::vector<std::__1::function<void
()>, std::__1::allocator<std::__1::function<void ()> > > const&, unsigned
long)::$_0&,
void>(StarQube::Thread::run(std::__1::vector<std::__1::function<void ()>,
std::__1::allocator<std::__1::function<void ()> > > const&, unsigned
long)::$_0&&&) <null> (TestHisto:x86_64+0x100e19156)
#2
std::__1::thread::thread<StarQube::Thread::run(std::__1::vector<std::__1::function<void
()>, std::__1::allocator<std::__1::function<void ()> > > const&, unsigned
long)::$_0&,
void>(StarQube::Thread::run(std::__1::vector<std::__1::function<void ()>,
std::__1::allocator<std::__1::function<void ()> > > const&, unsigned
long)::$_0&&&) <null> (TestHisto:x86_64+0x100e18848)
#3
StarQube::Thread::Thread<StarQube::Thread::run(std::__1::vector<std::__1::function<void
()>, std::__1::allocator<std::__1::function<void ()> > > const&, unsigned
long)::$_0&>(StarQube::String const&,
StarQube::Thread::run(std::__1::vector<std::__1::function<void ()>,
std::__1::allocator<std::__1::function<void ()> > > const&, unsigned
long)::$_0&&&) <null> (TestHisto:x86_64+0x100e1845a)
#4
StarQube::Thread::Thread<StarQube::Thread::run(std::__1::vector<std::__1::function<void
()>, std::__1::allocator<std::__1::function<void ()> > > const&, unsigned
long)::$_0&>(StarQube::String const&,
StarQube::Thread::run(std::__1::vector<std::__1::function<void ()>,
std::__1::allocator<std::__1::function<void ()> > > const&, unsigned
long)::$_0&&&) <null> (TestHisto:x86_64+0x100e17dd8)
#5 StarQube::Thread::run(std::__1::vector<std::__1::function<void ()>,
std::__1::allocator<std::__1::function<void ()> > > const&, unsigned long)
<null> (TestHisto:x86_64+0x100e1779d)
#6 TestHisto::testHisto(StarQube::QuantClient const&, StarQube::String
const&) <null> (TestHisto:x86_64+0x100017839)
#7 TestHisto::main() <null> (TestHisto:x86_64+0x100030cb1)
#8 StarQube::runSuite(char const*, void (*)(), bool) <null>
(TestHisto:x86_64+0x100032414)
#9 main <null> (TestHisto:x86_64+0x10003219c)
SUMMARY: ThreadSanitizer: data race
(/tmp/Compiler_2017-04-12_193601/StarQube/Config/CMake/build/TestHisto:x86_64+0x1000418a4)
in std::__1::binomial_distribution<unsigned
int>::param_type::param_type(unsigned int, double)
==================
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20170413/3b1bc22e/attachment.html>
More information about the llvm-bugs
mailing list