Skip to content

Commit 75f9391

Browse files
committed
Soft WDT: detect deliberate infinite loop at Postmortem
1 parent c517bfd commit 75f9391

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

cores/esp8266/core_esp8266_postmortem.cpp

+7-1
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,13 @@ static void postmortem_report(uint32_t sp_dump) {
181181
exccause, epc1, rst_info.epc2, rst_info.epc3, rst_info.excvaddr, rst_info.depc);
182182
}
183183
else if (rst_info.reason == REASON_SOFT_WDT_RST) {
184-
ets_printf_P(PSTR("\nSoft WDT reset\n"));
184+
ets_printf_P(PSTR("\nSoft WDT reset"));
185+
const char infinite_loop[] = { 0x06, 0xff, 0xff }; // loop: j loop
186+
if (0 == memcmp_P((void*)rst_info.epc1, infinite_loop, 3u)) {
187+
// The SDK is riddled with these. They are usually preceded by an ets_printf.
188+
ets_printf_P(PSTR(" - deliberate infinite loop detected"));
189+
}
190+
ets_putc('\n');
185191
ets_printf_P(PSTR("\nException (%d):\nepc1=0x%08x epc2=0x%08x epc3=0x%08x excvaddr=0x%08x depc=0x%08x\n"),
186192
rst_info.exccause, /* Address executing at time of Soft WDT level-1 interrupt */ rst_info.epc1, 0, 0, 0, 0);
187193
}

0 commit comments

Comments
 (0)