I'm trying to use Heap Task Tracking to debug some issues with memory leaks.
Calling heap_caps_print_all_task_stat_overview or heap_caps_print_all_task_stat causes a deadlock in my project because fprintf/vfprintf which is used by those functions ultimately causes heap_caps_malloc to be called, which attempts to update the task heap tracking statistics (via heap_caps_update_per_task_info_alloc), which are locked by a mutex at the start of those functions!
In the example (https://github.com/espressif/esp-idf/tr ... king/basic) this doesn't appear to happen since the fprintf calls never appear to try to allocate heap. I can't work out why the example behaves differently.
Is this expected behaviour, or am I doing something wrong here? =]
Cheers!
Heap Task Tracking Issues
-
MicroController
- Posts: 2661
- Joined: Mon Oct 17, 2022 7:38 pm
- Location: Europe, Germany
Re: Heap Task Tracking Issues
Probably not expected but a bug in the IDF, see also viewtopic.php?t=46280 and https://github.com/espressif/esp-idf/issues/17232
-
themainframe
- Posts: 3
- Joined: Wed Dec 20, 2017 2:48 pm
Re: Heap Task Tracking Issues
I found the issue in my case.
The problem was that elsewhere in the project, bufferless access to stdout/stdin (typical of using the linenoise console on a UART I believe) was set:
This makes fprintf use heap allocations. As I mentioned, during heap_caps_print_all_task_stat_overview and related functions, the heap statistics structures are locked by s_task_tracking_mutex, which means heap allocations further down the stack will result in deadlock.
Cheers!
The problem was that elsewhere in the project, bufferless access to stdout/stdin (typical of using the linenoise console on a UART I believe) was set:
Code: Select all
setvbuf(stdin, NULL, _IONBF, 0);
setvbuf(stdout, NULL, _IONBF, 0);
Cheers!
Who is online
Users browsing this forum: Applebot and 3 guests