Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e9bff95e authored by Lee Shombert's avatar Lee Shombert
Browse files

Do not freeze system_server

In early testing, freezing the current process generated an error but
did no harm.  Now it does harm.  This CL disables freezing because of
an ANR timeout if the target pid is 0 (often passed in to signify
"self") or the pid of system_server.

Flag: com.android.server.utils.anr_timer_freezer
Bug: 391491604
Test: atest
 * FrameworksServicesTests:AnrTimerTest
 * FrameworksServicesTests:com.android.server.am
 * FrameworksMockingServicesTests:com.android.server.am
Change-Id: I78189987f4dee398a02f6ca50df9d4e1a83b5419
parent 82da37e4
Loading
Loading
Loading
Loading
+8 −2
Original line number Original line Diff line number Diff line
@@ -101,6 +101,9 @@ nsecs_t now() {
    return systemTime(SYSTEM_TIME_MONOTONIC);
    return systemTime(SYSTEM_TIME_MONOTONIC);
}
}


// The current process.  This is cached here on startup.
const pid_t sThisProcess = getpid();

// Return true if the process exists and false if we cannot know.
// Return true if the process exists and false if we cannot know.
bool processExists(pid_t pid) {
bool processExists(pid_t pid) {
    char path[PATH_MAX];
    char path[PATH_MAX];
@@ -726,7 +729,7 @@ class AnrTimerService::Timer {
            uid(uid),
            uid(uid),
            timeout(timeout),
            timeout(timeout),
            extend(extend),
            extend(extend),
            freeze(pid != 0 && freeze),
            freeze(freeze),
            split(trace.earlyTimeout),
            split(trace.earlyTimeout),
            action(trace.action),
            action(trace.action),
            status(Running),
            status(Running),
@@ -1188,8 +1191,11 @@ const char* AnrTimerService::statusString(Status s) {
}
}


AnrTimerService::timer_id_t AnrTimerService::start(int pid, int uid, nsecs_t timeout) {
AnrTimerService::timer_id_t AnrTimerService::start(int pid, int uid, nsecs_t timeout) {
    // Use the freezer only if the pid is not 0 (a nonsense value) and the pid is not self.
    // Freezing the current process is a fatal error.
    bool useFreezer = freeze_ && (pid != 0) && (pid != sThisProcess);
    AutoMutex _l(lock_);
    AutoMutex _l(lock_);
    Timer t(pid, uid, timeout, extend_, freeze_, tracer_.getConfig(pid));
    Timer t(pid, uid, timeout, extend_, useFreezer, tracer_.getConfig(pid));
    insertLocked(t);
    insertLocked(t);
    t.start();
    t.start();
    counters_.started++;
    counters_.started++;