Page 1 of 1

Tracking down cause of Guru Meditation Error in Wifi related to wifi_malloc

Posted: Tue Apr 30, 2024 2:25 pm
by Timmwardion
I'm getting a Guru Meditation Error that seems to be related to Wifi. But I can't figure out the cause of it. The Wifi task seems incredibly hard to get info on or to tweak in terms of stack size etc. So I'm a bit stumped and wondering if any of you have any ideas. Here is my register dump and backtrace - getting to the bottom of this is especially hard because none of the code I've written is mentioned in the backtrace at all. I should say - running this on a regular 'ole ESP32-WROOM.

Code: Select all

Guru Meditation Error: Core  0 panic'ed (LoadStoreAlignment). Exception was unhandled.

Core  0 register dump:
PC      : 0x40090c92  PS      : 0x00060f33  A0      : 0x80090630  A1      : 0x3ffc33c0  
0x40090c92: remove_free_block at /Users/[user]/esp/esp-idf/components/heap/tlsf/tlsf.c:332
 (inlined by) block_locate_free at /Users/[user]/esp/esp-idf/components/heap/tlsf/tlsf.c:567
 (inlined by) tlsf_malloc at /Users/[user]/esp/esp-idf/components/heap/tlsf/tlsf.c:1015

A2      : 0x3ffafe68  A3      : 0x0000000c  A4      : 0x00060720  A5      : 0x3ffc3618  
A6      : 0x00000138  A7      : 0x3ffae6f4  A8      : 0x00000003  A9      : 0xa0030000  
A10     : 0x00000000  A11     : 0x40597736  A12     : 0x00000008  A13     : 0x3ffae718  
A14     : 0xbfffffff  A15     : 0x0000cdcd  SAR     : 0x0000001d  EXCCAUSE: 0x00000009  
EXCVADDR: 0x40597742  LBEG    : 0x4000c2e0  LEND    : 0x4000c2f6  LCOUNT  : 0xffffffff  
0x4000c2e0: memcpy in ROM
0x4000c2f6: memcpy in ROM



Backtrace: 0x40090c8f:0x3ffc33c0 0x4009062d:0x3ffc33e0 0x40082dd7:0x3ffc3400 0x40082bce:0x3ffc3420 0x40082c26:0x3ffc34a0 0x40082284:0x3ffc34c0 0x400822b9:0x3ffc34e0 0x40093355:0x3ffc3500 0x40086371:0x3ffc3520 0x4010c111:0x3ffc3540 0x4009766f:0x3ffc3580 0x40097917:0x3ffc35d0 0x4009527e:0x3ffc3610 0x4008de65:0x3ffc3640
0x40090c8f: remove_free_block at /Users/[user]/esp/esp-idf/components/heap/tlsf/tlsf.c:331 (discriminator 1)
 (inlined by) block_locate_free at /Users/[user]/esp/esp-idf/components/heap/tlsf/tlsf.c:567 (discriminator 1)
 (inlined by) tlsf_malloc at /Users/[user]/esp/esp-idf/components/heap/tlsf/tlsf.c:1015 (discriminator 1)
0x4009062d: multi_heap_malloc_impl at /Users/[user]/esp/esp-idf/components/heap/multi_heap.c:211
0x40082dd7: heap_caps_malloc_base at /Users/[user]/esp/esp-idf/components/heap/heap_caps_base.c:131
0x40082bce: trace_malloc at /Users/[user]/esp/esp-idf/components/heap/include/heap_trace.inc:116
0x40082c26: __wrap_heap_caps_malloc_base at /Users/[user]/esp/esp-idf/components/heap/include/heap_trace.inc:178
0x40082284: heap_caps_malloc at /Users/[user]/esp/esp-idf/components/heap/heap_caps.c:84
0x400822b9: heap_caps_malloc_default at /Users/[user]/esp/esp-idf/components/heap/heap_caps.c:110
0x40093355: malloc at /Users/[user]/esp/esp-idf/components/newlib/heap.c:24
0x40086371: wifi_malloc at /Users/[user]/esp/esp-idf/components/esp_wifi/esp32/esp_adapter.c:81
0x4010c111: wDev_SnifferRxData at ??:?
0x4009766f: wDev_ProcessRxSucData at ??:?
0x40097917: wdevProcessRxSucDataAll at ??:?
0x4009527e: ppTask at ??:?
0x4008de65: vPortTaskWrapper at /Users/[user]/esp/esp-idf/components/freertos/FreeRTOS-Kernel/portable/xtensa/port.c:134

Re: Tracking down cause of Guru Meditation Error in Wifi related to wifi_malloc

Posted: Wed May 01, 2024 2:26 am
by ESP_Sprite
It's a memory issue; some code somewhere overflowed a buffer or something and overwrote some metadata the heap allocator uses. Later on, the WiFi stack tried to do something with the heap allocator and it crashed when trying to parse the corrupted data. Sorry, there's no easy way to track down where the corruption happened, just be on the lookout for things like buffer overflows and use-after-free situations in your code.