Stack Overflow Error after enabling MQTT

vibro_tech
Posts: 7
Joined: Wed May 27, 2020 2:07 pm

Stack Overflow Error after enabling MQTT

Postby vibro_tech » Thu Aug 27, 2020 10:40 am

Hi,
I have been working on esp32-wroom-32u + ESP-IDF + Eclipse with different sensors. There were no problem. I wanted to try a new sensor which has 512 * 7 byte FIFO memory. I get strange errors and could not find a solution. The code works like this:
1. Initialize NVS
2. Initialize Wifi and connect.
3. Initialize MQTT client, register and start.
4. Initialize SPI communication with sensor
5. Collect data from sensor over FIFO with multiple times ( FIFO capacity is 512 * 7 byte but I need to collect 4000 *7 byte)
6. Send collected data over MQTT

As I said above, I used this code with different sensors. when I use with lastest one: I get below error:
Heap summary for capabilities 0x00001000:
At 0x3ffae6e0 len 6432 free 0 allocated 6296 min_free 0
largest_free_block 0 alloc_blocks 26 free_blocks 0 total_blocks 26
At 0x3ffbb048 len 151480 free 80880 allocated 69688 min_free 78656
largest_free_block 80216 alloc_blocks 218 free_blocks 2 total_blocks 220
At 0x3ffe0440 len 15072 free 15036 allocated 0 min_free 15036
largest_free_block 15036 alloc_blocks 0 free_blocks 1 total_blocks 1
At 0x3ffe4350 len 113840 free 113804 allocated 0 min_free 113804
largest_free_block 113804 alloc_blocks 0 free_blocks 1 total_blocks 1
Totals:
free 209720 allocated 75984 min_free 207496 largest_free_block 113804
Heap summary for capabilities 0x00001000:
At 0x3ffae6e0 len 6432 free 0 allocated 6296 min_free 0
largest_free_block 0 alloc_blocks 26 free_blocks 0 total_blocks 26
At 0x3ffbb048 len 151480 free 77796 allocated 72760 min_free 77796
largest_free_block 77132 alloc_blocks 221 free_blocks 2 total_blocks 223
At 0x3ffe0440 len 15072 free 15036 allocated 0 min_free 15036
largest_free_block 15036 alloc_blocks 0 free_blocks 1 total_blocks 1
At 0x3ffe4350 len 113840 free 113804 allocated 0 min_free 113804
largest_free_block 113804 alloc_blocks 0 free_blocks 1 total_blocks 1
Totals:
free 206636 allocated 79056 min_free 204936 largest_free_block 113804
Heap summary for capabilities 0x00001000:
At 0x3ffae6e0 len 6432 free 0 allocated 6296 min_free 0
largest_free_block 0 alloc_blocks 26 free_blocks 0 total_blocks 26
At 0x3ffbb048 len 151480 free 74184 allocated 76360 min_free 74184
largest_free_block 73520 alloc_blocks 224 free_blocks 2 total_blocks 226
At 0x3ffe0440 len 15072 free 15036 allocated 0 min_free 15036
largest_free_block 15036 alloc_blocks 0 free_blocks 1 total_blocks 1
At 0x3ffe4350 len 113840 free 113804 allocated 0 min_free 113804
largest_free_block 113804 alloc_blocks 0 free_blocks 1 total_blocks 1
Totals:
free 203024 allocated 82656 min_free 203024 largest_free_block 113804
I (22302) TP: F:: 512

I (22312) TP: Start Fifo Count: 512

***ERROR*** A stack overflow in task main has been detected.
abort() was called at PC 0x40087a44 on core 0

ELF file SHA256: 08235ae667e64226

Backtrace: 0x40087699:0x3ffbbda0 0x40087a2d:0x3ffbbdc0 0x40087a44:0x3ffbbde0 0x4008907f:0x3ffbbe00 0x400882a4:0x3ffbbe20 0x4008825a:0x40130838 |<-CORRUPTED

Rebooting...
ets Jun 8 2016 00:22:57
If I disable (or not initialize MQTT), then there is no problem. I can collect data without any error. I check the heap memory with below code:
heap_caps_print_heap_info(MALLOC_CAP_DEFAULT);
I used this short code in my whole code as shown below.:
heap_caps_print_heap_info(MALLOC_CAP_DEFAULT);

int16_t *rx, *ry, *rz;
rx = malloc(512 * sizeof(int16_t));
ry = malloc(512 * sizeof(int16_t));
rz = malloc(512 * sizeof(int16_t));

int16_t eSize = 300;
int16_t eCount = 0;

heap_caps_print_heap_info(MALLOC_CAP_DEFAULT);

float *ex, *ey, *ez;
ex = malloc(eSize * sizeof(float));
ey = malloc(eSize * sizeof(float));
ez = malloc(eSize * sizeof(float));

heap_caps_print_heap_info(MALLOC_CAP_DEFAULT);
I thought it is a memory problem. I searched but I could not find any clue.

Thanks in advance

ESP-Marius
Posts: 74
Joined: Wed Oct 23, 2019 1:49 am

Re: Stack Overflow Error after enabling MQTT

Postby ESP-Marius » Fri Aug 28, 2020 1:11 am

Your warning says stack overflow in task main, but you are looking at/debugging your heap memory.

Did you try to increase the size of the stack for main? The setting for this can be found in:

Code: Select all

Component config -> Common ESP-related -> Main task size

vibro_tech
Posts: 7
Joined: Wed May 27, 2020 2:07 pm

Re: Stack Overflow Error after enabling MQTT

Postby vibro_tech » Wed Dec 09, 2020 7:27 am

Hi @ESP-Marius,
First of all, sorry for late reply. I god some issues with Covid but I covered.
Your solution solved the issue. Thanks for the guidance

Best regards

Who is online

Users browsing this forum: Gaston1980 and 79 guests