Francois Echantillac
unread,Sep 28, 2016, 5:10:02 PM9/28/16Sign in to reply to author
Sign in to forward
Sign in to report message as abuse
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to googl...@googlegroups.com, Ming Zhao
Hello,
Using Clang thread sanitizer with gmock 1.7.0 I'm facing a race in the
gmock library. I built a mock which is used by a thread (T2 here), then
trying to set an expectation on it using the EXPECT_CALL macro. Tsan
doesn't seem happy about it, see below for the relevant portions of the
stacktraces.
From what I can tell it looks like the race happens on
untyped_expectations_ as its access is not protected.
Is that a bug or is that use case unsupported ?
Thank you!
Francois
WARNING: ThreadSanitizer: data race (pid=1)
Read of size 8 at 0x7d700001b9c8 by thread T2 (mutexes: write M156):
#0
std::vector<testing::internal::linked_ptr<testing::internal::ExpectationBase>,
std::allocator<testing::internal::linked_ptr<testing::internal::ExpectationBase>
> >::size() const
/usr/crosstool/v2/gcc-4.9.1-lrtev1/x86/lib/gcc/x86_64-unknown-linux-gnu/4.9.x-google/../../../../include/c++/4.9.x-google/bits/stl_vector.h:728:2
(x2gw-simple-enb_test+0x000000a4219b)
#1
testing::internal::UntypedFunctionMockerBase::UntypedInvokeWith(void
const*)
/usr/local/home/_bazel_francois/189fc812c7ed18873b09b97c3ce9a0d2/main/third_party/google/gmock/src/gmock-spec-builders.cc:338:7
(x2gw-simple-enb_test+0x000000db7bcb)
#2 testing::internal::FunctionMockerBase<void
(net::masc::AsnContext<lte::X2apProtoParams>*,
x2ap::ENBConfigurationUpdate*)>::InvokeWith(std::tuple<net::masc::AsnContext<lte::X2apProtoParams>*,
x2ap::ENBConfigurationUpdate*> const&)
/usr/local/home/_bazel_francois/189fc812c7ed18873b09b97c3ce9a0d2/main/third_party/google/gmock/include/gmock/gmock-spec-builders.h:1585:34
(x2gw-simple-enb_test+0x000000a61444)
#3 testing::internal::FunctionMocker<void
(net::masc::AsnContext<lte::X2apProtoParams>*,
x2ap::ENBConfigurationUpdate*)>::Invoke(net::masc::AsnContext<lte::X2apProtoParams>*,
x2ap::ENBConfigurationUpdate*)
/usr/local/home/_bazel_francois/189fc812c7ed18873b09b97c3ce9a0d2/main/third_party/google/gmock/include/gmock/gmock-generated-function-mockers.h:125:12
(x2gw-simple-enb_test+0x000000a613ff)
...
Previous write of size 8 at 0x7d700001b9c8 by main thread:
#0 void
std::vector<testing::internal::linked_ptr<testing::internal::ExpectationBase>,
std::allocator<testing::internal::linked_ptr<testing::internal::ExpectationBase>
>
>::_M_emplace_back_aux<testing::internal::linked_ptr<testing::internal::ExpectationBase> const&>(testing::internal::linked_ptr<testing::internal::ExpectationBase> const&) /usr/crosstool/v2/gcc-4.9.1-lrtev1/x86/lib/gcc/x86_64-unknown-linux-gnu/4.9.x-google/../../../../include/c++/4.9.x-google/bits/vector.tcc:479:2 (x2gw-simple-enb_test+0x000000a41fc5)
#1
std::vector<testing::internal::linked_ptr<testing::internal::ExpectationBase>,
std::allocator<testing::internal::linked_ptr<testing::internal::ExpectationBase>
>
>::push_back(testing::internal::linked_ptr<testing::internal::ExpectationBase> const&) /usr/crosstool/v2/gcc-4.9.1-lrtev1/x86/lib/gcc/x86_64-unknown-linux-gnu/4.9.x-google/../../../../include/c++/4.9.x-google/bits/stl_vector.h:1049:4 (x2gw-simple-enb_test+0x000000a419c7)
#2 testing::internal::FunctionMockerBase<void
(net::masc::AsnContext<lte::X2apProtoParams>*,
x2ap::ENBConfigurationUpdate*)>::AddNewExpectation(char const*, int,
std::string const&,
std::tuple<testing::Matcher<net::masc::AsnContext<lte::X2apProtoParams>*>,
testing::Matcher<x2ap::ENBConfigurationUpdate*> > const&)
/usr/local/home/_bazel_francois/189fc812c7ed18873b09b97c3ce9a0d2/main/third_party/google/gmock/include/gmock/gmock-spec-builders.h:1611:5
(x2gw-simple-enb_test+0x000000a417b2)
#3 testing::internal::MockSpec<void
(net::masc::AsnContext<lte::X2apProtoParams>*,
x2ap::ENBConfigurationUpdate*)>::InternalExpectedAt(char const*, int,
char const*, char const*)
/usr/local/home/_bazel_francois/189fc812c7ed18873b09b97c3ce9a0d2/main/third_party/google/gmock/include/gmock/gmock-spec-builders.h:1272:12
(x2gw-simple-enb_test+0x000000a3f678)
...