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

Commit 8fb6e3fd authored by Woody Lin's avatar Woody Lin
Browse files

InitFatalReboot: Trigger panic explicitly for init_fatal_panic

The exit of init panics the system *after* process context (mm, stack,
...etc.) are recycled, according to Linux kernel's 'do_exit'
implementation. To preserve most init process context for debugging,
triggers the panic via proc-sysrq explicitly.

Note: after this change, there will be no "Attempt to kill init" panic
when androidboot.init_fatal_panic is set.

Test: Insert data abort fault in init, the full process context is
      preserved in memory dump captured after panic.
Bug: 155940351
Change-Id: I3393bd00f99b8cb432cfa19a105b7d636b411764
(cherry picked from commit be1cf900)
parent c00d57d3
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -66,8 +66,6 @@
#include "sigchld_handler.h"
#include "util.h"

#define PROC_SYSRQ "/proc/sysrq-trigger"

using namespace std::literals;

using android::base::boot_clock;
+4 −0
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@
#include <cutils/android_reboot.h>

#include "capabilities.h"
#include "reboot_utils.h"

namespace android {
namespace init {
@@ -138,6 +139,9 @@ void __attribute__((noreturn)) InitFatalReboot(int signal_number) {
        LOG(ERROR) << backtrace->FormatFrameData(i);
    }
    if (init_fatal_panic) {
        LOG(ERROR) << __FUNCTION__ << ": Trigger crash";
        android::base::WriteStringToFile("c", PROC_SYSRQ);
        LOG(ERROR) << __FUNCTION__ << ": Sys-Rq failed to crash the system; fallback to exit().";
        _exit(signal_number);
    }
    RebootSystem(ANDROID_RB_RESTART2, init_fatal_reboot_target);
+2 −0
Original line number Diff line number Diff line
@@ -18,6 +18,8 @@

#include <string>

#define PROC_SYSRQ "/proc/sysrq-trigger"

namespace android {
namespace init {