esp-idf: spinlock_acquire assertion fail (IDFGH-10048)
Answers checklist.
- I have read the documentation ESP-IDF Programming Guide and the issue is not addressed there.
- I have updated my IDF branch (master or release) to the latest version and checked that the issue is present there.
- I have searched the issue tracker for a similar issue and not found a similar issue.
General issue report
I’ve been using ESP-IDF v4.4
(but I have updated to the latest release, v4.4-dev-3540-g4e03a9c34c
- I can’t use anything after v4.4
because websockets were removed) on my ESP32-S3 DevkitC-1 N32R8V and have been having no problems. But suddenly, with no changes other than rebuilding ESP-IDF, I now get frequent crashes from spinlock_acquire
. I get the following error message:
assert failed: spinlock_acquire spinlock.h:122 (result == core_id || result == SPINLOCK_FREE)
In some cases I get a different error from compare_set.h
, which appears to come from a function called just prior to the assertion in spinlock_acquire
. There’s no error message for this other than a panic message and a stack trace including compare_set
at the top:
Guru Meditation Error: Core 0 panic'ed (StoreProhibited). Exception was unhandled.
...
0x403805cd - compare_and_set_native
at /home/devin/Desktop/netsblox-vm-esp32/.embuild/espressif/esp-idf/release-v4.4/components/esp_hw_support/include/soc/compare_set.h:25
0x403834e9 - vPortEnterCritical
at /home/devin/Desktop/netsblox-vm-esp32/.embuild/espressif/esp-idf/release-v4.4/components/freertos/port/xtensa/include/freertos/portmacro.h:578
0x40383516 - multi_heap_malloc_impl
at /home/devin/Desktop/netsblox-vm-esp32/.embuild/espressif/esp-idf/release-v4.4/components/heap/multi_heap.c:186
0x403769bb - heap_caps_malloc_base
at /home/devin/Desktop/netsblox-vm-esp32/.embuild/espressif/esp-idf/release-v4.4/components/heap/heap_caps.c:175
0x40376a0c - heap_caps_malloc_default
at /home/devin/Desktop/netsblox-vm-esp32/.embuild/espressif/esp-idf/release-v4.4/components/heap/heap_caps.c:230
0x403842a5 - malloc
at /home/devin/Desktop/netsblox-vm-esp32/.embuild/espressif/esp-idf/release-v4.4/components/newlib/heap.c:24
...
It seems that it’s calling compare_and_set_native
, which may be incorrect because I have SPI RAM support enabled and accessibe through malloc. Altohugh it looks like this is specifically an error caused by dynamic allocation, rather than the mutex lock. However, it seems the common thread between these issues is the compare_and_set
function. Possibly related to #9120 since I am also using SPI RAM on an ESP32-S3.
The specific interaction that causes this is when I perform an HTTPS request to the device with the https server component, which then writes to NVS. It may be some complex interaction between these. The problem occurs in general with some, but not all, dynamic allocations with malloc
(more details below). Also, because it only started doing this recently, I think it is likely some (relatively) recent change to the ESP-IDF I’ve reverted my version of ESP-IDF back to the version when my project was last working (from a clean build), and the problem persists (more details below).v4.4
release.
About this issue
- Original URL
- State: closed
- Created a year ago
- Comments: 35 (1 by maintainers)
No problem, thanks for replying so soon 😃
Here is the log and backtrace:
I am using platformio version
6.1.7
with arduino espressif core6.1.0
which has Arduino Corev2.0.7
The example is my project located here - we have functioning support already for most Camera-based ESP32 boards.
If it is more relevant i can move my issue to the platformio-espressif32 repo, i only started my inquiry here as this issue is the same error we are facing. Though, only in relation to the esp32s3 xiao boards.