From d366845ec7f99817b078f92f2b983b7f5c1ce31f Mon Sep 17 00:00:00 2001 From: Jeremy Nimmer Date: Tue, 30 Oct 2018 11:05:29 -0400 Subject: [PATCH] lcm: Prime the LCM self-test before launching threads --- lcm/drake_lcm.cc | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lcm/drake_lcm.cc b/lcm/drake_lcm.cc index a909a7ddd825..8b3081703710 100644 --- a/lcm/drake_lcm.cc +++ b/lcm/drake_lcm.cc @@ -31,6 +31,13 @@ DrakeLcm::~DrakeLcm() { receive_thread_.reset(); } void DrakeLcm::StartReceiveThread() { DRAKE_DEMAND(receive_thread_ == nullptr); + + // Ensure that LCM's self-test happens before our thread starts running. + // Without this, ThreadSanitizer builds may report false positives related to + // the self-test happening concurrently with the LCM publishing. + lcm_.getFileno(); + + // Now launch the thread. receive_thread_ = std::make_unique(&lcm_); }