mathieucarbou / AsyncTCP

Async TCP Library for ESP32
GNU Lesser General Public License v3.0
7 stars 2 forks source link

assert failed: tcp_update_rcv_ann_wnd #14

Open DaeMonSxy opened 1 week ago

DaeMonSxy commented 1 week ago

It would be good to have an internal crash prevention for asynctcp library as well. I would appreciate any hints to solve such crashes-and have stable tcp lib also.

` assert failed: tcp_update_rcv_ann_wnd IDF/components/lwip/lwip/src/core/tcp.c:951 (new_rcv_ann_wnd <= 0xffff)

Backtrace: 0x40083d65:0x3ffb34d0 0x4008ca75:0x3ffb34f0 0x4009209d:0x3ffb3510 0x40127c06:0x3ffb3640 0x40127cb4:0x3ffb3660 0x400f4662:0x3ffb3680 0x4012498c:0x3ffb36a0

0 0x40083d65 in panic_abort at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/esp_system/panic.c:408

1 0x4008ca75 in esp_system_abort at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/esp_system/esp_system.c:137

2 0x4009209d in __assert_func at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/newlib/assert.c:85

3 0x40127c06 in tcp_update_rcv_ann_wnd at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/lwip/lwip/src/core/tcp.c:951

  (inlined by) tcp_update_rcv_ann_wnd at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/lwip/lwip/src/core/tcp.c:931

4 0x40127cb4 in tcp_recved at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/lwip/lwip/src/core/tcp.c:991

5 0x400f4662 in _tcp_recved_api(tcpip_api_call_data*) at /Users/daemons/platformio_libdeps/ESP32/Async TCP/src/AsyncTCP.cpp:444

6 0x4012498c in tcpip_thread_handle_msg at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/lwip/lwip/src/api/tcpip.c:172

  (inlined by) tcpip_thread at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/lwip/lwip/src/api/tcpip.c:154

`

mathieucarbou commented 1 week ago

Hello, Please have a look at https://github.com/mathieucarbou/AsyncTCP?tab=readme-ov-file#important-recommendations And let me know also which board / pio config you are using.

DaeMonSxy commented 1 week ago

theoretically I have it in platformio,

build_flags =
-D CONFIG_ASYNC_TCP_QUEUE_SIZE=128      ; Async TCP queue size
-D CONFIG_ASYNC_TCP_RUNNING_CORE=1      ; Async TCP async task core
-D CONFIG_ASYNC_TCP_STACK_SIZE=8096     ; Async TCP async stac ksize
-D WS_MAX_QUEUED_MESSAGES=64            ; WebSocket queue size
;-D CONFIG_ASYNC_TCP_PRIORITY=10         ; ask priority
;-D CONFIG_ASYNC_TCP_MAX_ACK_TIME=3000   ;
mathieucarbou commented 1 week ago

Seems related to the queue size ? Ref: https://github.com/me-no-dev/AsyncTCP/issues/88

It's hard to help you with so little information. How the application is built, uses ressources and how many request / concurrent request you have can all affect that.

If you can pinpoint a bit more the issue, let me know.

DaeMonSxy commented 1 week ago

Well, hard to tell the exact crash location in lib.

Having several modules built in top of asynctcp including webserver.All of those are using asyncTCP, which part makes asynctcp to crash is a good question, however, I would expect asyncTCP to handle the receive window - heap or stack , or any error may accur -so somehow i would epect the lib internally to be more crash-proof.

mathieucarbou commented 1 week ago

Did you try to switch to these forks:

Mine is a fork from esphome, with some fixes added that were in standing PRs from me-no-dev.

I would suggest to do other rounds of testing to at least test whether the issue is also in all repo, or just this one.

If just this one, it means one if the proposed fixes that was merged had a side effect - this is not impossible, but I think less probable.

I know several people who prefer AsyncTCPSock, but it takes a little more memory and there are less heap allocation spikes with AsyncTCP.