lock_acquire_generic problem

esmaxness
Posts: 6
Joined: Fri May 27, 2022 12:16 pm

lock_acquire_generic problem

Postby esmaxness » Fri May 27, 2022 12:48 pm

Hello everybody,

I am facing a problem with my ESP32 project. It appears the following message:

Code: Select all

abort() was called at PC 0x40082b77 on core 0
0x40082b77: lock_acquire_generic at C:/Esp32/esp-idf/components/newlib/locks.c:138


Backtrace:0x4008805b:0x3ffbb5b0 0x4008882d:0x3ffbb5d0 0x4008f86e:0x3ffbb5f0 0x40082b77:0x3ffbb660 0x40082cc1:0x3ffbb690 0x40131fed:0x3ffbb6b0 0x4012dddd:0x3ffbb970 0x4012dd65:0x3ffbb9c0 0x4008d5c7:0x3ffbb9f0 0x4008dc9f:0x3ffbba10 0x4008df58:0x3ffbba30 0x40081889:0x3ffbba50 0x400818bd:0x3ffbba70 0x4008f879:0x3ffbba90 0x4008476d:0x3ffbbab0 0x400fbc19:0x3ffbbad0 0x401050ed:0x3ffbbaf0 0x401022c9:0x3ffbbb10 0x400d48c5:0x3ffbbb30 0x400d48ee:0x3ffbbb60 0x4008be5d:0x3ffbbb80
0x4008805b: panic_abort at C:/Esp32/esp-idf/components/esp_system/panic.c:356

0x4008882d: esp_system_abort at C:/Esp32/esp-idf/components/esp_system/system_api.c:112

0x4008f86e: abort at C:/Esp32/esp-idf/components/newlib/abort.c:46

0x40082b77: lock_acquire_generic at C:/Esp32/esp-idf/components/newlib/locks.c:138

0x40082cc1: _lock_acquire_recursive at C:/Esp32/esp-idf/components/newlib/locks.c:166

0x40131fed: _vfiprintf_r at /builds/idf/crosstool-NG/.build/HOST-x86_64-w64-mingw32/xtensa-esp32-elf/src/newlib/newlib/libc/stdio/vfprintf.c:853 (discriminator 2)

0x4012dddd: fiprintf at /builds/idf/crosstool-NG/.build/HOST-x86_64-w64-mingw32/xtensa-esp32-elf/src/newlib/newlib/libc/stdio/fiprintf.c:48

0x4012dd65: __assert_func at /builds/idf/crosstool-NG/.build/HOST-x86_64-w64-mingw32/xtensa-esp32-elf/src/newlib/newlib/libc/stdlib/assert.c:58 (discriminator 8)

0x4008d5c7: block_locate_free at C:/Esp32/esp-idf/components/heap/heap_tlsf.c:447
 (inlined by) tlsf_malloc at C:/Esp32/esp-idf/components/heap/heap_tlsf.c:757

0x4008dc9f: multi_heap_malloc_impl at C:/Esp32/esp-idf/components/heap/multi_heap.c:197

0x4008df58: multi_heap_malloc at C:/Esp32/esp-idf/components/heap/multi_heap_poisoning.c:230

0x40081889: heap_caps_malloc at C:/Esp32/esp-idf/components/heap/heap_caps.c:145

0x400818bd: heap_caps_malloc_default at C:/Esp32/esp-idf/components/heap/heap_caps.c:177

0x4008f879: malloc at C:/Esp32/esp-idf/components/newlib/heap.c:31

0x4008476d: wifi_malloc at C:/Esp32/esp-idf/components/esp_wifi/esp32/esp_adapter.c:79

0x400fbc19: ieee80211_timer_process at ??:?

0x401050ed: pp_timer_process at ??:?

0x401022c9: lmac_stop_hw_txq at ??:?

0x400d48c5: timer_process_alarm at C:/Esp32/esp-idf/components/esp_timer/src/esp_timer.c:330

0x400d48ee: timer_task at C:/Esp32/esp-idf/components/esp_timer/src/esp_timer.c:349 (discriminator 1)

0x4008be5d: vPortTaskWrapper at C:/Esp32/esp-idf/components/freertos/port/xtensa/port.c:168
I am not sure why this happends.
Could you please help to me to find the error

ESP_Sprite
Posts: 8921
Joined: Thu Nov 26, 2015 4:08 am

Re: lock_acquire_generic problem

Postby ESP_Sprite » Fri May 27, 2022 1:32 pm

Looks like the original problem is that you trigger an assert in the memory allocator, which 99% of the time indicates memory corruption.

esmaxness
Posts: 6
Joined: Fri May 27, 2022 12:16 pm

Re: lock_acquire_generic problem

Postby esmaxness » Mon May 30, 2022 11:26 am

I have not set assertions in my code. Or what do you mind?

ESP_Sprite
Posts: 8921
Joined: Thu Nov 26, 2015 4:08 am

Re: lock_acquire_generic problem

Postby ESP_Sprite » Tue May 31, 2022 1:56 am

What I mean is that it looks like you're corrupting some memory that belongs to the heap allocator (the thing that handles malloc() and free()), perhaps by writing more to a buffer than the size of the buffer can contain. Then later on, the WiFi stack tries to do something that involves the heap allocator; the heap allocator at that point sees its memory is corrupted and that triggers an assert(). However, for some reason, that assert tries to print something while the ESP32 is in a weird state and this triggers the 2nd error that ends up in lock_acquire_generic .

Suggest you read up on heap corruption debugging, the solution to your issue can most likely be found there.

esmaxness
Posts: 6
Joined: Fri May 27, 2022 12:16 pm

Re: lock_acquire_generic problem

Postby esmaxness » Wed Jun 01, 2022 5:34 pm

Thank you. I have resolved the issue using heap_caps_check_integrity() until reaching the overflowed buffer.

Who is online

Users browsing this forum: Bing [Bot] and 118 guests