----------------------------------------------------------- This is an automatically generated e-mail. To reply, visit: https://reviews.apache.org/r/26783/#review57188 -----------------------------------------------------------
Hey Joris, Can you file a JIRA ticket on the issue? Also, do you know why multiple threads where calling the destructor? - Niklas Nielsen On Oct. 15, 2014, 2:55 p.m., Joris Van Remoortere wrote: > > ----------------------------------------------------------- > This is an automatically generated e-mail. To reply, visit: > https://reviews.apache.org/r/26783/ > ----------------------------------------------------------- > > (Updated Oct. 15, 2014, 2:55 p.m.) > > > Review request for mesos, Benjamin Hindman and Niklas Nielsen. > > > Repository: mesos-git > > > Description > ------- > > There is a race condition in Latch. The same pid can be terminated by 2 > seperate threads simultaneously. > > > Diffs > ----- > > 3rdparty/libprocess/src/latch.cpp 89185ec > > Diff: https://reviews.apache.org/r/26783/diff/ > > > Testing > ------- > > make check > > The following test could segfault before: (after this patch it does not) > > ``` > auto do_launch = []() { > std::mutex mut; > std::condition_variable cond; > bool ready = true; > Latch *latch = new Latch(); > const size_t num_iter = 10000; > std::thread t1([&]() { > for (size_t i = 0; i < num_iter; ++i) { > { > std::unique_lock<std::mutex> lock(mut); > while (!ready) { > cond.wait(lock); > } > ready = false; > } > latch->trigger(); > } > }); > std::thread t2([&]() { > for (size_t i = 0; i < num_iter; ++i) { > latch->await(); > delete latch; > latch = new Latch(); > std::lock_guard<std::mutex> lock(mut); > ready = true; > cond.notify_one(); > } > }); > t1.join(); > t2.join(); > }; > const size_t nthread = 16; > std::vector<std::thread> tvec; > for (size_t i = 0; i < nthread; ++i) { > tvec.emplace_back(do_launch); > } > for (auto& t : tvec) { > t.join(); > } > ``` > > > Thanks, > > Joris Van Remoortere > >
