Merge "Fix use-after-pthread_exit in a test."
This commit is contained in:
commit
3f8bdb216c
|
@ -337,11 +337,14 @@ struct TestBug37410 {
|
||||||
static void* thread_fn(void* arg) {
|
static void* thread_fn(void* arg) {
|
||||||
TestBug37410* data = reinterpret_cast<TestBug37410*>(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.
|
// Let the main thread know we're running.
|
||||||
pthread_mutex_unlock(&data->mutex);
|
pthread_mutex_unlock(&data->mutex);
|
||||||
|
|
||||||
// And wait for the main thread to exit.
|
// And wait for the main thread to exit.
|
||||||
pthread_join(data->main_thread, nullptr);
|
pthread_join(main_thread, nullptr);
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue