Logging from allocation trace hooks fails (LoadProhibited @_vfprintf_r)
Posted: Wed May 31, 2023 5:42 am
We're currently fixing a notorious memory leak and wanted to try out the memory allocation hooks
This is not working however as the app crashes because of vfprintf accessing some prohibited memory:
I had this before when I tried to inject logs into FreeRTOS functions and it's very annoying. Why does this happen and how can I fix it quickly?
Code: Select all
#include "esp_heap_caps.h"
void esp_heap_trace_alloc_hook(void* ptr, size_t size, uint32_t caps)
{
printf("heap alloc of %zu bytes @%p", size, ptr);
}
void esp_heap_trace_free_hook(void* ptr)
{
printf("heap free @%p", ptr);
}
Code: Select all
Guru Meditation Error: Core 0 panic'ed (LoadProhibited). Exception was unhandled.
Core 0 register dump:
PC : 0x401803e0 PS : 0x00060930 A0 : 0x80177978 A1 : 0x3ffe34f0
0x401803e0: _vfprintf_r at /builds/idf/crosstool-NG/.build/HOST-x86_64-w64-mingw32/xtensa-esp32-elf/src/newlib/newlib/libc/stdio/vfprintf.c:849 (discriminator 14)
A2 : 0x3ff96458 A3 : 0x3ffe3500 A4 : 0x3f405528 A5 : 0x3ffe3840
A6 : 0x3ffe3820 A7 : 0x00000004 A8 : 0x00000000 A9 : 0x3ffe34d0
A10 : 0x00000000 A11 : 0x3ffe3744 A12 : 0x000000ff A13 : 0x0000ff00
A14 : 0x00ff0000 A15 : 0xff000000 SAR : 0x0000001e EXCCAUSE: 0x0000001c
EXCVADDR: 0x00000064 LBEG : 0x4000c2e0 LEND : 0x4000c2f6 LCOUNT : 0x00000000
I had this before when I tried to inject logs into FreeRTOS functions and it's very annoying. Why does this happen and how can I fix it quickly?