Android-x86
Fork
Donation

  • R/O
  • HTTP
  • SSH
  • HTTPS

system-extras: 提交

system/extras


Commit MetaInfo

修订版42f318af0b5730ea7835ad4ea124311747c9c3c5 (tree)
时间2019-06-04 03:55:09
作者Pirama Arumuga Nainar <pirama@goog...>
CommiterOliver Nguyen

Log Message

Do not create property_watch_loop thread for zygote

Bug: http://b/116873221
Bug: http://b/133872559

Do not create thread running property_watch_loop for zygote (which is
essentially /system/bin/app_process invoked with a specific argument to
start the zygote).

The reason this is needed is because when the zygote forks system_server
or an app, it waits for all threads to stop. But the thread created
here doesn't know that it has to stop. So zygote gets stuck waiting and
the device doesn't boot.

This check is only needed for the platform, but can be done on any
version after Android L, when getprogname() was added.

Test: cuttlefish with coverage enabled can boot.
Change-Id: I65aa603a88bf8da1f14b5c4ada3adf3776f33275
(cherry picked from commit 4cedcc68d4dfedf96474973de1e7e22d0ce0a523)

更改概述

差异

--- a/toolchain-extras/profile-extras.cpp
+++ b/toolchain-extras/profile-extras.cpp
@@ -17,7 +17,9 @@
1717 #include <errno.h>
1818 #include <pthread.h>
1919 #include <signal.h>
20+#include <stdlib.h>
2021 #include <string.h>
22+#include <libgen.h> // For POSIX basename().
2123
2224 // Use _system_properties.h to use __system_property_wait_any()
2325 #define _REALLY_INCLUDE_SYS__SYSTEM_PROPERTIES_H_
@@ -84,6 +86,20 @@ __attribute__((constructor)) int init_profile_extras(void) {
8486 return -1;
8587 }
8688
89+ // Do not create thread running property_watch_loop for zygote (it can get
90+ // invoked as zygote or app_process). This check is only needed for the
91+ // platform, but can be done on any version after Android L, when
92+ // getprogname() was added.
93+#if defined(__ANDROID_API__) && __ANDROID_API__ >= __ANDROID_API_L__
94+ const char *prog_basename = basename(getprogname());
95+ if (strncmp(prog_basename, "zygote", strlen("zygote")) == 0) {
96+ return 0;
97+ }
98+ if (strncmp(prog_basename, "app_process", strlen("app_process")) == 0) {
99+ return 0;
100+ }
101+#endif
102+
87103 pthread_t thread;
88104 int error = pthread_create(&thread, nullptr, property_watch_loop, nullptr);
89105 if (error != 0) {
Show on old repository browser