Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 57fa6cd

Browse filesBrowse files
authored
Soft WDT: detect deliberate infinite loop at Postmortem (esp8266#8918)
A popular method of handling an unrecoverable state is to reboot. The SDK does this in many places by printing a cryptic debug message followed by something equivalent to while(true){}, which compiles down to loop: j loop, creating a Soft WDT reset.
1 parent c517bfd commit 57fa6cd
Copy full SHA for 57fa6cd

File tree

Expand file treeCollapse file tree

1 file changed

+7
-1
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+7
-1
lines changed

‎cores/esp8266/core_esp8266_postmortem.cpp

Copy file name to clipboardExpand all lines: cores/esp8266/core_esp8266_postmortem.cpp
+7-1Lines changed: 7 additions & 1 deletion
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(infinite_loop, (PGM_VOID_P)rst_info.epc1, 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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.