Page 1 of 1

Stack overflow on emacT when disconnecting Ethernet

Posted: Tue Sep 04, 2018 11:52 am
by Resch2061
Hi,

When trying to stop the Ethernet functions in ESP-IDF v3.1, I'm getting a stack overflow in the emac_task:

Code: Select all

I (4243) COMMS: Connected Ethernet

W (4535) COMMS: Disconnecting comms!
I (4535) MQTTplain: Disconnecting!
I (5536) ETHERNET: Stopping
mem_usage: free DRAM 173888 IRAM 239264
I (5537) emac: emac stop
I (5537***ERROR*** A stack overflow in task emacT has been detected.
abort() was called at PC 0x4008e120 on core 0
0x4008e120: vApplicationStackOverflowHook at /home/rene/esp32/apps/josuino_esp32/esp-idf/components/esp32/panic.c:649


Backtrace: 0x4008e0db:0x3ffcb040 0x4008e107:0x3ffcb060 0x4008e120:0x3ffcb080 0x4008b47e:0x3ffcb0a0 0x4008c910:0x3ffcb0d0 0x4008c8c6:0x020073b3
0x4008e0db: invoke_abort at /home/rene/esp32/apps/josuino_esp32/esp-idf/components/esp32/panic.c:649

0x4008e107: abort at /home/rene/esp32/apps/josuino_esp32/esp-idf/components/esp32/panic.c:649

0x4008e120: vApplicationStackOverflowHook at /home/rene/esp32/apps/josuino_esp32/esp-idf/components/esp32/panic.c:649

0x4008b47e: vTaskSwitchContext at /home/rene/esp32/apps/josuino_esp32/esp-idf/components/freertos/tasks.c:3564

0x4008c910: _frxt_dispatch at /home/rene/esp32/apps/josuino_esp32/esp-idf/components/freertos/portasm.S:406

0x4008c8c6: _frxt_int_exit at /home/rene/esp32/apps/josuino_esp32/esp-idf/components/freertos/portasm.S:206
As you can see, it's only 4-5 seconds in the program. You can also see how much DRAM and IRAM we're using just before the stack overflow.
It's quite cumbersome this is happening. Not sure how to resolve this, myself.

Re: Stack overflow on emacT when disconnecting Ethernet

Posted: Wed Sep 05, 2018 6:49 am
by ESP_morris
Since the stack size of emacT is 2048 Bytes, and currently it can not be changed in driver(I don't know why the original author do so...)
So, thanks for your post, I will make the stack size of emacT task "mutable" via Kconfig.
If your project is in a hurry, you can try to change the stack size from 2048 to 4096 in components/ethernet/emac_main.c
Image

Re: Stack overflow on emacT when disconnecting Ethernet

Posted: Thu Sep 06, 2018 1:30 pm
by Resch2061
Thank you for your reply.
I'm mostly wondering myself why this even occurs in the first place. It runs just fine most of the time, it's just when we're switching from Wifi to Ethernet this happens, which I find rather odd. Again, there's quite a few tasks running in our program beside emacT. I'm looking into it further myself, I will let you know when I discover more about this issue.