Code Crashing in IDLE
Posted: Wed Aug 16, 2023 7:48 pm
I'm a fairly new user to the ESP32 & FreeRtos. I'm developing an application for the LilyGo T-Beam, and using the Arduino framework and platformio. My code will run for multiple hours, and then randomly crash. I have a core dump that refers to a crashed IDLE task. All of the core dumps I'm capturing now are essentially the same.
If someone could help me better understand the contents of the core dump, and potentially where I could look next, it would be a huge help. And if there's something obvious I'm doing wrong, please let me know.
My initial interpretation is that the Idle task's stack is being overflowed, but I don't know what would cause that stack to overflow, or how to increase the size of it.
In the course of debugging, I've pinned all of the tasks that I'm running to Core 1, just to eliminate the possibility of the communication between the two cores being a cause. Inside the arduino loop function, I'm calling vTaskDelete(NULL) to immediately stop that task, but the reboot is still occurring. The debug message just prior to the reboot indicates a stack smashing protect error, but I'm not sure what stack it's referring to. I've given all of the tasks that I create an abundance of space for their stacks.
The message I get in my debug window just prior to the reboot is below.
---------------------------------------------------------------------------------------------------
Stack smashing protect failure!
abort() was called at PC 0x400f0cac on core 1
Backtrace: 0x400840b1:0x3ffbf26c |<-CORRUPTED
ELF file SHA256: 20e7f869ec436344
-----------------------------------------------------------------------------------------------------
The crashed task's call stack shows that a panic abort is occurring in esp_crosscore_int_send_yield(). I couldn't find documentation on this function, but from the name, I suspect it has something to do with communication between tasks on separate cores.
As I mentioned, I've pinned all of my tasks to Core 1. But entry 6 refers to core 0.
5 process 1073415304 0x40083ff4 in esp_crosscore_int_send_yield (core_id=1) at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/esp_system/crosscore_int.c:144
6 process 1073468196 0x40083ff4 in esp_crosscore_int_send_yield (core_id=0) at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/esp_system/crosscore_int.c:144
7 process 1073439200 0x40083ff4 in esp_crosscore_int_send_yield (core_id=1) at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/esp_system/crosscore_int.c:144
If someone could help me better understand the contents of the core dump, and potentially where I could look next, it would be a huge help. And if there's something obvious I'm doing wrong, please let me know.
My initial interpretation is that the Idle task's stack is being overflowed, but I don't know what would cause that stack to overflow, or how to increase the size of it.
In the course of debugging, I've pinned all of the tasks that I'm running to Core 1, just to eliminate the possibility of the communication between the two cores being a cause. Inside the arduino loop function, I'm calling vTaskDelete(NULL) to immediately stop that task, but the reboot is still occurring. The debug message just prior to the reboot indicates a stack smashing protect error, but I'm not sure what stack it's referring to. I've given all of the tasks that I create an abundance of space for their stacks.
The message I get in my debug window just prior to the reboot is below.
---------------------------------------------------------------------------------------------------
Stack smashing protect failure!
abort() was called at PC 0x400f0cac on core 1
Backtrace: 0x400840b1:0x3ffbf26c |<-CORRUPTED
ELF file SHA256: 20e7f869ec436344
-----------------------------------------------------------------------------------------------------
The crashed task's call stack shows that a panic abort is occurring in esp_crosscore_int_send_yield(). I couldn't find documentation on this function, but from the name, I suspect it has something to do with communication between tasks on separate cores.
As I mentioned, I've pinned all of my tasks to Core 1. But entry 6 refers to core 0.
5 process 1073415304 0x40083ff4 in esp_crosscore_int_send_yield (core_id=1) at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/esp_system/crosscore_int.c:144
6 process 1073468196 0x40083ff4 in esp_crosscore_int_send_yield (core_id=0) at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/esp_system/crosscore_int.c:144
7 process 1073439200 0x40083ff4 in esp_crosscore_int_send_yield (core_id=1) at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/esp_system/crosscore_int.c:144
Code: Select all
===============================================================
==================== ESP32 CORE DUMP START ====================
Crashed task handle: 0x3ffbd1bc, name: 'IDLE', GDB name: 'process 1073467836'
================== CURRENT THREAD REGISTERS ===================
exccause 0x1d (StoreProhibitedCause)
excvaddr 0x0
epc1 0x400f04cd
epc2 0x0
epc3 0x0
epc4 0x0
epc5 0x0
epc6 0x0
eps2 0x0
eps3 0x0
eps4 0x0
eps5 0x0
eps6 0x0
pc 0x400840b4 0x400840b4 <panic_abort+24>
lbeg 0x40087239 1074295353
lend 0x4008725b 1074295387
lcount 0x0 0
sar 0x10 16
ps 0x60a21 395809
threadptr <unavailable>
br <unavailable>
scompare1 <unavailable>
acclo <unavailable>
acchi <unavailable>
m0 <unavailable>
m1 <unavailable>
m2 <unavailable>
m3 <unavailable>
expstate <unavailable>
f64r_lo <unavailable>
f64r_hi <unavailable>
f64s <unavailable>
fcr <unavailable>
fsr <unavailable>
a0 0x8008b4a4 -2146913116
a1 0x3ffbf26c 1073476204
a2 0x3ffbf2d6 1073476310
a3 0x3ffbf303 1073476355
a4 0xa 10
a5 0x0 0
a6 0x3ffb9794 1073452948
a7 0x0 0
a8 0x0 0
a9 0x1 1
a10 0x3ffbf2ba 1073476282
a11 0x3ffbf2ba 1073476282
a12 0xa 10
a13 0x60623 394787
a14 0x60621 394785
a15 0x1 1
==================== CURRENT THREAD STACK =====================
#0 0x400840b4 in panic_abort (details=0x3ffbf2d6 "abort() was called at PC 0x400f0cac on core 1") at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/esp_system/panic.c:408
#1 0x4008b4a4 in esp_system_abort (details=0x3ffbf2d6 "abort() was called at PC 0x400f0cac on core 1") at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/esp_system/esp_system.c:137
Backtrace stopped: previous frame identical to this frame (corrupt stack?)
======================== THREADS INFO =========================
Id Target Id Frame
* 1 process 1073467836 0x400840b4 in panic_abort (details=0x3ffbf2d6 "abort() was called at PC 0x400f0cac on core 1") at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/esp_system/panic.c:408
2 process 1073453172 0x40083ff4 in esp_crosscore_int_send_yield (core_id=1) at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/esp_system/crosscore_int.c:144
3 process 1073466436 0x40131016 in esp_pm_impl_waiti () at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/hal/esp32/include/hal/cpu_ll.h:183
4 process 1073413308 0x40083ff4 in esp_crosscore_int_send_yield (core_id=1) at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/esp_system/crosscore_int.c:144
5 process 1073415304 0x40083ff4 in esp_crosscore_int_send_yield (core_id=1) at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/esp_system/crosscore_int.c:144
6 process 1073468196 0x40083ff4 in esp_crosscore_int_send_yield (core_id=0) at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/esp_system/crosscore_int.c:144
7 process 1073439200 0x40083ff4 in esp_crosscore_int_send_yield (core_id=1) at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/esp_system/crosscore_int.c:144
8 process 1073436744 0x40083ff4 in esp_crosscore_int_send_yield (core_id=1) at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/esp_system/crosscore_int.c:144
9 process 1073459408 0x4000bff0 in ?? ()
10 process 1073443980 0x40083fdc in esp_crosscore_int_send (core_id=<optimized out>, reason_mask=1) at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/esp_system/crosscore_int.c:125
11 process 1073445680 0x40083ff4 in esp_crosscore_int_send_yield (core_id=1) at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/esp_system/crosscore_int.c:144
12 process 1073426616 0x40083ff4 in esp_crosscore_int_send_yield (core_id=1) at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/esp_system/crosscore_int.c:144
13 process 1073427876 0x40083ff4 in esp_crosscore_int_send_yield (core_id=1) at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/esp_system/crosscore_int.c:144
==================== THREAD 1 (TCB: 0x3ffbd1bc, name: 'IDLE') =====================
#0 0x400840b4 in panic_abort (details=0x3ffbf2d6 "abort() was called at PC 0x400f0cac on core 1") at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/esp_system/panic.c:408
#1 0x4008b4a4 in esp_system_abort (details=0x3ffbf2d6 "abort() was called at PC 0x400f0cac on core 1") at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/esp_system/esp_system.c:137
Backtrace stopped: previous frame identical to this frame (corrupt stack?)
==================== THREAD 2 (TCB: 0x3ffb9874, name: 'Event Queue') =====================
#0 0x40083ff4 in esp_crosscore_int_send_yield (core_id=1) at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/esp_system/crosscore_int.c:144
#1 0x4008c32a in xQueueReceive (xQueue=0x3ffb9748, pvBuffer=0x3ffc31f8 <g_Event>, xTicksToWait=<optimized out>) at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/hal/esp32/include/hal/cpu_ll.h:39
#2 0x400dbdcc in EventQueue::processIncomingEvents (this=0x3ffb8b64) at src/libMyApp/Events/EventQueue.cpp:104
#3 0x400dbe6a in EventQueue_Task (parameter=0x3ffb8b64) at src/libMyApp/Events/EventQueue.cpp:250
==================== THREAD 3 (TCB: 0x3ffbcc44, name: 'IDLE') =====================
#0 0x40131016 in esp_pm_impl_waiti () at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/hal/esp32/include/hal/cpu_ll.h:183
#1 0x400f14a9 in esp_vApplicationIdleHook () at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/esp_system/freertos_hooks.c:63
#2 0x4008c8af in prvIdleTask (pvParameters=<optimized out>) at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/tasks.c:3987
==================== THREAD 4 (TCB: 0x3ffafcbc, name: 'MyApp Loop ') =====================
#0 0x40083ff4 in esp_crosscore_int_send_yield (core_id=1) at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/esp_system/crosscore_int.c:144
#1 0x4008d8bc in vTaskDelay (xTicksToDelay=500) at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/hal/esp32/include/hal/cpu_ll.h:39
#2 0x400d2c3e in MyAppLoop_Task (parameter=<optimized out>) at src/MyApp_main.cpp:80
==================== THREAD 5 (TCB: 0x3ffb0488, name: 'Pressure Read T') =====================
#0 0x40083ff4 in esp_crosscore_int_send_yield (core_id=1) at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/esp_system/crosscore_int.c:144
#1 0x4008d8bc in vTaskDelay (xTicksToDelay=2000) at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/hal/esp32/include/hal/cpu_ll.h:39
#2 0x400db4ee in PressureUpdate_Task (parameter=0x3ffb8de8) at src/libMyApp/Drivers/Sensata_PTE7300.cpp:230
==================== THREAD 6 (TCB: 0x3ffbd324, name: 'Tmr Svc') =====================
#0 0x40083ff4 in esp_crosscore_int_send_yield (core_id=0) at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/esp_system/crosscore_int.c:144
#1 0x4008e4f2 in prvProcessTimerOrBlockTask (xListWasEmpty=<optimized out>, xNextExpireTime=6841444) at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/hal/esp32/include/hal/cpu_ll.h:39
#2 prvTimerTask (pvParameters=<optimized out>) at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/timers.c:597
==================== THREAD 7 (TCB: 0x3ffb61e0, name: 'Health Check') =====================
#0 0x40083ff4 in esp_crosscore_int_send_yield (core_id=1) at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/esp_system/crosscore_int.c:144
#1 0x4008d8bc in vTaskDelay (xTicksToDelay=120000) at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/hal/esp32/include/hal/cpu_ll.h:39
#2 0x400d2c01 in HealthCheck_Task (parameter=<optimized out>) at src/MyApp_main.cpp:93
==================== THREAD 8 (TCB: 0x3ffb5848, name: 'PWM Update') =====================
#0 0x40083ff4 in esp_crosscore_int_send_yield (core_id=1) at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/esp_system/crosscore_int.c:144
#1 0x4008d8bc in vTaskDelay (xTicksToDelay=252966867) at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/hal/esp32/include/hal/cpu_ll.h:39
#2 0x400db0a4 in PWMUpdate_Task (parameter=0x3ffb8ba4) at src/libMyApp/Drivers/PWM.cpp:328
==================== THREAD 9 (TCB: 0x3ffbb0d0, name: 'esp_timer') =====================
#0 0x4000bff0 in ?? ()
#1 0x4008e920 in vPortClearInterruptMaskFromISR (prev_level=<optimized out>) at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/port/xtensa/include/freertos/portmacro.h:571
#2 vPortExitCritical (mux=<optimized out>) at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/port/xtensa/port.c:332
#3 0x4008ddbd in ulTaskGenericNotifyTake (uxIndexToWait=<optimized out>, xClearCountOnExit=1, xTicksToWait=4294967295) at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/tasks.c:5401
#4 0x400f5a71 in timer_task (arg=<optimized out>) at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/esp_timer/src/esp_timer.c:384
==================== THREAD 10 (TCB: 0x3ffb748c, name: 'ipc0') =====================
#0 0x40083fdc in esp_crosscore_int_send (core_id=<optimized out>, reason_mask=1) at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/esp_system/crosscore_int.c:125
#1 0x40083ff4 in esp_crosscore_int_send_yield (core_id=0) at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/esp_system/crosscore_int.c:144
#2 0x4008c490 in xQueueSemaphoreTake (xQueue=0x3ffb7018, xTicksToWait=<optimized out>) at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/hal/esp32/include/hal/cpu_ll.h:39
#3 0x40085ec7 in ipc_task (arg=<optimized out>) at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/esp_ipc/src/esp_ipc.c:54
==================== THREAD 11 (TCB: 0x3ffb7b30, name: 'ipc1') =====================
#0 0x40083ff4 in esp_crosscore_int_send_yield (core_id=1) at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/esp_system/crosscore_int.c:144
#1 0x4008c490 in xQueueSemaphoreTake (xQueue=0x3ffb76bc, xTicksToWait=<optimized out>) at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/hal/esp32/include/hal/cpu_ll.h:39
#2 0x40085ec7 in ipc_task (arg=<optimized out>) at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/esp_ipc/src/esp_ipc.c:54
==================== THREAD 12 (TCB: 0x3ffb30b8, name: 'LoRa Send Queue') =====================
#0 0x40083ff4 in esp_crosscore_int_send_yield (core_id=1) at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/esp_system/crosscore_int.c:144
#1 0x4008c32a in xQueueReceive (xQueue=0x3ffb2d34, pvBuffer=0x3ffd0ba4, xTicksToWait=<optimized out>) at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/hal/esp32/include/hal/cpu_ll.h:39
#2 0x400ddddd in LoRaMsgQueue::process (this=0x3ffb92f8) at src/libMyApp/LoRa/Queues/LoRaMsgQueue.cpp:155
#3 0x400ddee6 in LoRaMsgQueue_Task (parameter=0x3ffb92f8) at src/libMyApp/LoRa/Queues/LoRaMsgQueue.cpp:262
==================== THREAD 13 (TCB: 0x3ffb35a4, name: 'LoRa Receive Qu') =====================
#0 0x40083ff4 in esp_crosscore_int_send_yield (core_id=1) at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/esp_system/crosscore_int.c:144
#1 0x4008c32a in xQueueReceive (xQueue=0x3ffb3220, pvBuffer=0x3ffd6bb4, xTicksToWait=<optimized out>) at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/hal/esp32/include/hal/cpu_ll.h:39
#2 0x400ddddd in LoRaMsgQueue::process (this=0x3ffb9380) at src/libMyApp/LoRa/Queues/LoRaMsgQueue.cpp:155
#3 0x400ddee6 in LoRaMsgQueue_Task (parameter=0x3ffb9380) at src/libMyApp/LoRa/Queues/LoRaMsgQueue.cpp:262
======================= ALL MEMORY REGIONS ========================
Name Address Size Attrs
.rtc.text 0x400c0000 0x0 RW
.rtc.dummy 0x3ff80000 0x0 RW
.rtc.force_fast 0x3ff80000 0x4 RW A
.rtc.force_slow 0x50000210 0x0 RW
.iram0.vectors 0x40080000 0x403 R XA
.iram0.text 0x40080404 0x11f57 R XA
.dram0.data 0x3ffbdb60 0x4f78 RW A
.ext_ram_noinit 0x3f800000 0x0 RW
.noinit 0x3ffc2ad8 0x0 RW
.ext_ram.bss 0x3f800000 0x0 RW
.flash.appdesc 0x3f400020 0x100 R A
.flash.rodata 0x3f400120 0x38edc RW A
.flash.rodata_noload 0x3f438ffc 0x0 RW
.flash.text 0x400d0020 0x63987 R XA
.iram0.data 0x4009235c 0x0 RW
.iram0.bss 0x4009235c 0x0 RW
.dram0.heap_start 0x3ffc6088 0x0 RW
.coredump.tasks.data 0x3ffb9874 0x158 RW
.coredump.tasks.data 0x3ffccaa0 0x1c0 RW
.coredump.tasks.data 0x3ffbd1bc 0x158 RW
.coredump.tasks.data 0x3ffbd020 0x180 RW
.coredump.tasks.data 0x3ffbcc44 0x158 RW
.coredump.tasks.data 0x3ffbcab0 0x180 RW
.coredump.tasks.data 0x3ffafcbc 0x158 RW
.coredump.tasks.data 0x3ffbc330 0x180 RW
.coredump.tasks.data 0x3ffb0488 0x158 RW
.coredump.tasks.data 0x3ffdeb20 0x180 RW
.coredump.tasks.data 0x3ffbd324 0x158 RW
.coredump.tasks.data 0x3ffc6a80 0x170 RW
.coredump.tasks.data 0x3ffb61e0 0x158 RW
.coredump.tasks.data 0x3ffafb20 0x180 RW
.coredump.tasks.data 0x3ffb5848 0x158 RW
.coredump.tasks.data 0x3ffb56b0 0x180 RW
.coredump.tasks.data 0x3ffbb0d0 0x158 RW
.coredump.tasks.data 0x3ffbaf10 0x1a0 RW
.coredump.tasks.data 0x3ffb748c 0x158 RW
.coredump.tasks.data 0x3ffb72b0 0x1c0 RW
.coredump.tasks.data 0x3ffb7b30 0x158 RW
.coredump.tasks.data 0x3ffb7970 0x1a0 RW
.coredump.tasks.data 0x3ffb30b8 0x158 RW
.coredump.tasks.data 0x3ffd0a80 0x1f0 RW
.coredump.tasks.data 0x3ffb35a4 0x158 RW
.coredump.tasks.data 0x3ffd6a90 0x1f0 RW
===================== ESP32 CORE DUMP END =====================
===============================================================