Merge "Fix use-after-pthread_exit in a test."

This commit is contained in:
Treehugger Robot 2019-02-06 16:42:47 +00:00 committed by Gerrit Code Review
commit 3f8bdb216c

View file

@ -337,11 +337,14 @@ struct TestBug37410 {
static void* thread_fn(void* arg) {
TestBug37410* data = reinterpret_cast<TestBug37410*>(arg);
// Unlocking data->mutex will cause the main thread to exit, invalidating *data. Save the handle.
pthread_t main_thread = data->main_thread;
// Let the main thread know we're running.
pthread_mutex_unlock(&data->mutex);
// And wait for the main thread to exit.
pthread_join(data->main_thread, nullptr);
pthread_join(main_thread, nullptr);
return nullptr;
}