mirror of
https://github.com/rstrouse/ESPSomfy-RTS.git
synced 2026-10-31 13:52:15 +01:00
fix: don't boot-loop on a corrupted coredump
setup() prints the stored coredump summary on every boot and trusted its backtrace depth. A half-written dump reads back as the 0xa5 stack fill, so depth was 0xa5a5a5a5: the loop read past bt[16], snprintf ran past its 256-byte buffer once the size went negative, and the interrupt watchdog reset the board. The dump stays in flash, so every boot hit it again (seen 2026-10-21: 162 TG1WDT resets in a row, each stopping after "Cause:"). formatBacktrace() in Utils reads at most bt[]'s 16 frames and stops when the buffer is full, and the line notes IDF's corrupted flag. The task name is printed at most 16 chars, since exc_task isn't always terminated. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
b74f382650
commit
54641af039
4 changed files with 53 additions and 7 deletions
|
|
@ -257,6 +257,35 @@ static void test_worthRoaming_any_ap_while_disconnected() {
|
|||
TEST_ASSERT_TRUE(worthRoaming(false, 0, -90, 6));
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* formatBacktrace
|
||||
********************************************************************/
|
||||
static void test_formatBacktrace_frames_the_dump_holds() {
|
||||
const uint32_t bt[16] = {0x40083c19, 0x4008e42d, 0x00000011};
|
||||
char buf[256];
|
||||
formatBacktrace(buf, sizeof(buf), bt, 16, 3);
|
||||
TEST_ASSERT_EQUAL_STRING(" 0x40083c19 0x4008e42d 0x00000011", buf);
|
||||
}
|
||||
static void test_formatBacktrace_garbage_depth_stays_in_bounds() {
|
||||
// A half-written dump reads back as the 0xa5 stack fill: depth 0xa5a5a5a5.
|
||||
// setup() looped that many times and overran bt[] and its buffer.
|
||||
struct { uint32_t bt[16]; uint32_t depth; } summary;
|
||||
memset(&summary, 0xa5, sizeof(summary));
|
||||
struct { char buf[256]; char guard[16]; } out;
|
||||
memset(out.guard, 'G', sizeof(out.guard));
|
||||
formatBacktrace(out.buf, sizeof(out.buf), summary.bt, 16, summary.depth);
|
||||
TEST_ASSERT_EQUAL(16 * 11, strlen(out.buf));
|
||||
for (size_t i = 0; i < sizeof(out.guard); i++) TEST_ASSERT_EQUAL_CHAR('G', out.guard[i]);
|
||||
}
|
||||
static void test_formatBacktrace_stops_when_the_buffer_is_full() {
|
||||
const uint32_t bt[16] = {0};
|
||||
struct { char buf[30]; char guard[16]; } out;
|
||||
memset(out.guard, 'G', sizeof(out.guard));
|
||||
formatBacktrace(out.buf, sizeof(out.buf), bt, 16, 16);
|
||||
TEST_ASSERT_EQUAL(sizeof(out.buf) - 1, strlen(out.buf));
|
||||
for (size_t i = 0; i < sizeof(out.guard); i++) TEST_ASSERT_EQUAL_CHAR('G', out.guard[i]);
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* wifiAuthModeName
|
||||
********************************************************************/
|
||||
|
|
@ -384,6 +413,9 @@ int main(int argc, char **argv) {
|
|||
RUN_TEST(test_worthRoaming_needs_the_full_gain);
|
||||
RUN_TEST(test_worthRoaming_never_to_a_weaker_ap);
|
||||
RUN_TEST(test_worthRoaming_any_ap_while_disconnected);
|
||||
RUN_TEST(test_formatBacktrace_frames_the_dump_holds);
|
||||
RUN_TEST(test_formatBacktrace_garbage_depth_stays_in_bounds);
|
||||
RUN_TEST(test_formatBacktrace_stops_when_the_buffer_is_full);
|
||||
RUN_TEST(test_wifiAuthModeName_matches_the_idf_enum);
|
||||
RUN_TEST(test_wifiAuthModeName_unknown_past_the_shared_values);
|
||||
RUN_TEST(test_heapEmitTarget_one_client_always_gets_it);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue