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

Commit b36ed85c authored by Colin Cross's avatar Colin Cross Committed by The Android Automerger
Browse files

trigger kernel blocked stack trace on system server watchdog

Bug b/7638530 may be caused by a kernel deadlock when killing
processes under low memory conditions.  Write to /proc/sysrq-trigger
to get a kernel log of blocked tasks before killing the system server.

Bug: 7638530
Change-Id: I60df324ad4affdadbf13650099dc4dfb38722420
parent 9341e671
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -39,6 +39,8 @@ import android.util.Log;
import android.util.Slog;

import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Calendar;

@@ -439,6 +441,16 @@ public class Watchdog extends Thread {
                dumpKernelStackTraces();
            }

            // Trigger the kernel to dump all blocked threads to the kernel log
            try {
                FileWriter sysrq_trigger = new FileWriter("/proc/sysrq-trigger");
                sysrq_trigger.write("w");
                sysrq_trigger.close();
            } catch (IOException e) {
                Slog.e(TAG, "Failed to write to /proc/sysrq-trigger");
                Slog.e(TAG, e.getMessage());
            }

            // Try to add the error to the dropbox, but assuming that the ActivityManager
            // itself may be deadlocked.  (which has happened, causing this statement to
            // deadlock and the watchdog as a whole to be ineffective)