Fix use-after-pthread_exit in a test.
HWASan reports access to a local variable after the owning thread has called pthread_exit. Bug: 114279110 Test: enable hwasan in tests/Android.bp; run pthread_DeathTest.pthread_bug_37410 Change-Id: Ic04a2b3dce092d7ab3cbefab1da64731e0c7afb9
This commit is contained in:
parent
de70b72b4f
commit
352853a535
|
@ -336,11 +336,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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue