~aleteoryx/muditaos

e9177f23aaab1e6ce0c3e89486e4980a2ef68a44 — Lucjan Bryndza 4 years ago f9dc8a1
[EGD-7996] Prevent crashdump recursion from ISR

Calling abort() or exit() from the interrupt context
causes that the phone enters into bootloop, because
in the exception mode ISR cannot be used.
We are add guards for prevent clean system shudown
when abort is called from the ISR context.

Signed-off-by: Lucjan Bryndza <lucjan.bryndza@mudita.com>
1 files changed, 12 insertions(+), 10 deletions(-)

M module-os/board/rt1051/_exit.cpp
M module-os/board/rt1051/_exit.cpp => module-os/board/rt1051/_exit.cpp +12 -10
@@ 44,17 44,19 @@

static void __attribute__((noreturn)) stop_system(void)
{
    if (dumpLogs() != 1) {
        LOG_ERROR("Cannot dump logs");
    }
    
    const auto err = purefs::subsystem::unmount_all();
    if(err) {
        LOG_WARN("Unable unmount all filesystems with error: %i.", err);
    } else {
        LOG_INFO("Filesystems unmounted successfully...");
    if(!isIRQ()) {
        if (dumpLogs() != 1) {
            LOG_ERROR("Cannot dump logs");
        }
        const auto err = purefs::subsystem::unmount_all();
        if(err) {
            LOG_WARN("Unable unmount all filesystems with error: %i.", err);
        } else {
            LOG_INFO("Filesystems unmounted successfully...");
        }
    }
    LOG_INFO("Restarting the system...");
    haltIfDebugging();
    vTaskEndScheduler();
    NVIC_SystemReset();
    // waiting for system reset


@@ 68,7 70,7 @@ static void __attribute__((noreturn)) stop_system(void)
void __attribute__((noreturn, used)) _exit_backtrace(int code, bool bt_dump)
{
    LOG_INFO("_exit %d", code);
    if( bt_dump ) {
    if( bt_dump && !isIRQ() ) {
        _StackTrace_Dump_And_Abort();
    }
    stop_system();