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 v4.4 release. 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).

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 35 (1 by maintainers)

Most upvoted comments

No problem, thanks for replying so soon 😃

Here is the log and backtrace:

assert failed: spinlock_acquire spinlock.h:122 (result == core_id || result == SPINLOCK_FREE)

Backtrace: 0x40377386:0x3fceb720 0x4037d47d:0x3fceb740 0x403840d1:0x3fceb760 0x40380995:0x3fceb890 0x40383a15:0x3fceb8d0 0x40383d15:0x3fceb8f0 0x403777cd:0x3fceb910 0x40377915:0x3fceb940 0x4037755e:0x3fceb9a0 0x40377571:0x3fceb9c0 0x42043336:0x3fceb9e0 0x4202a2a2:0x3fceba00 0x42096b7b:0x3fceba20 0x42097377:0x3fcebbb0 0x42097490:0x3fcebbd0 0x42098700:0x3fcebbf0 0x4200a366:0x3fcebd60 0x4200aaf5:0x3fcebdd0 0x42003c55:0x3fcebe10 0x4200410f:0x3fcebe60 0x42010b9f:0x3fcebeb0

I am using platformio version 6.1.7 with arduino espressif core 6.1.0 which has Arduino Core v2.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.

Note: i just saw here that the platform-espressif32 for pio has an update that adds support for the SeeedStudio Xiao ESP32S3 and some other esp32s3 based boards - so i will upgrade and try again later today and report back if that resolves the issue.