audioserver: Use '_exit' instead of 'exit' in HalDeathHandler
Using 'exit' from an RPC threadpool thread is not safe, as 'exit'
runs atexit handlers that destroy global objects. This can interfere
with code still running on other threads.
'_exit' does not run atexit handlers, just terminates the process.
Bug: 116665972
Test: kill android.hardware.audio@2.0-service, check logcat
Change-Id: I5391a659e359e0ca5bba580f1c51dea5df3ea562
diff --git a/media/libaudiohal/HalDeathHandlerHidl.cpp b/media/libaudiohal/HalDeathHandlerHidl.cpp
index 1e3ab58..6e33523 100644
--- a/media/libaudiohal/HalDeathHandlerHidl.cpp
+++ b/media/libaudiohal/HalDeathHandlerHidl.cpp
@@ -54,7 +54,7 @@
handler.second();
}
ALOGE("HAL server crashed, audio server is restarting");
- exit(1);
+ _exit(1); // Avoid calling atexit handlers, as this code runs on a thread from RPC threadpool.
}
} // namespace android