espressif / arduino-esp32

Arduino core for the ESP32
GNU Lesser General Public License v2.1
13.52k stars 7.39k forks source link

AsyncTCP crash after 1-2 days #9519

Closed skowron0 closed 6 months ago

skowron0 commented 6 months ago

Board

Xiao ESP32-C3

Device Description

Im use custom board with pullup resistor to sensor and mosfets to led control.

Hardware Configuration

Using ADC, LEDC

Version

latest master (checkout manually)

IDE Name

PlatformIO

Operating System

Windows 10

Flash frequency

80Mhz

PSRAM enabled

no

Upload speed

115200

Description

I get a crash every 1-2 days. I activated coredump to analyze the problem. Reports a problem in AsyncServer::_accept, line "if(_connect_cb){". Could anyone tell me what the problem is? How to patch it?

Sketch

//runs on LwIP thread
int8_t AsyncServer::_accept(tcp_pcb* pcb, int8_t err){
    //ets_printf("+A: 0x%08x\n", pcb);
    if(_connect_cb){
        AsyncClient *c = new AsyncClient(pcb);
        if(c){
            c->setNoDelay(_noDelay);
            return _tcp_accept(this, c);
        }
    }
    if(tcp_close(pcb) != ERR_OK){
        tcp_abort(pcb);
    }
    log_e("FAIL");
    return ERR_OK;
}

Debug Message

===============================================================
==================== ESP32 CORE DUMP START ====================

Crashed task handle: 0x3fc9d9bc, name: 'tiT', GDB name: 'process 1070193084'

================== CURRENT THREAD REGISTERS ===================
ra             0x4203aaac       0x4203aaac <tcp_input+3082>
sp             0x3fc9d870       0x3fc9d870
gp             0x3fc8e600       0x3fc8e600 <g_wifi_osi_funcs+436>
tp             0x3fc6ecb8       0x3fc6ecb8
t0             0x6      6
t1             0x218a5ea7       562716327
t2             0xac07a8c0       -1408784192
fp             0x3fcb5468       0x3fcb5468
s1             0x3fc994a0       1070175392
a0             0x0      0
a1             0x3fcb5468       1070290024
a2             0x0      0
a3             0x3fcb3ca4       1070283940
a4             0x0      0
a5             0x4209500a       1107906570
a6             0x0      0
a7             0x0      0
s2             0x3fc9a000       1070178304
s3             0x3fc9949a       1070175386
s4             0x3fc99494       1070175380
s5             0x3fc994a4       1070175396
s6             0x3fc9a000       1070178304
s7             0x3fc99498       1070175384
s8             0x3fc9949c       1070175388
s9             0x3fc94ca8       1070156968
s10            0x3fc994ba       1070175418
s11            0x10     16
t3             0x0      0
t4             0x0      0
t5             0x3fcb5468       1070290024
t6             0x0      0
pc             0x42094f46       0x42094f46 <AsyncServer::_accept(tcp_pcb*, signed char)+12>

==================== CURRENT THREAD STACK =====================
#0  0x42094f46 in AsyncServer::_accept (this=0x0, pcb=0x3fcb5468, err=0 '\000') at .pio/libdeps/seeed_xiao_esp32c3_OTA/AsyncTCP/src/AsyncTCP.cpp:1296
#1  0x4203aaac in tcp_process (pcb=0x3fcb5468) at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/lwip/lwip/src/core/tcp_in.c:945
#2  tcp_input (p=p@entry=0x3fc9cc30, inp=inp@entry=0x3fca4bc0) at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/lwip/lwip/src/core/tcp_in.c:438
#3  0x4204075e in ip4_input (p=p@entry=0x3fc9cc30, inp=inp@entry=0x3fca4bc0) at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/lwip/lwip/src/core/ipv4/ip4.c:803
#4  0x42044eca in ethernet_input (p=0x3fc9cc30, netif=0x3fca4bc0) at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/lwip/lwip/src/netif/ethernet.c:186
#5  0x42033eca in tcpip_thread_handle_msg (msg=0x3fc9cc58) at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/lwip/lwip/src/api/tcpip.c:180
#6  tcpip_thread (arg=<optimized out>) at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/lwip/lwip/src/api/tcpip.c:154
#7  0x40389c90 in prvTaskExitError () at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/port/riscv/port.c:133
Backtrace stopped: frame did not save the PC

======================== THREADS INFO =========================
  Id   Target Id          Frame
* 1    process 1070193084 0x42094f46 in AsyncServer::_accept (this=0x0, pcb=0x3fcb5468, err=0 '\000') at .pio/libdeps/seeed_xiao_esp32c3_OTA/AsyncTCP/src/AsyncTCP.cpp:1296
  2    process 1070196408 0x420538da in esp_pm_impl_waiti () at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/esp_pm/pm_impl.c:849
  3    process 1070206652 0x40389d62 in vPortYield () at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/port/riscv/port.c:327
  4    process 1070215780 0x40389d62 in vPortYield () at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/port/riscv/port.c:327
  5    process 1070220248 0x40389d62 in vPortYield () at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/port/riscv/port.c:327
  6    process 1070265560 0x40389d62 in vPortYield () at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/port/riscv/port.c:327
  7    process 1070283360 0x40389d62 in vPortYield () at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/port/riscv/port.c:327
  8    process 1070187996 0x40389cfe in vPortClearInterruptMask (mask=1) at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/port/riscv/port.c:308
  9    process 1070232624 0x40389d62 in vPortYield () at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/port/riscv/port.c:327

       TCB             NAME PRIO C/B  STACK USED/FREE
---------- ---------------- -------- ----------------
0x3fc9d9bc              tiT    18/18         320/2740
0x3fc9e6b8             IDLE      0/0         192/2104
0x3fca0ebc         loopTask      1/1         192/7988
0x3fca3264          sys_evt    20/20         336/2220
0x3fca43d8   arduino_events    19/19         272/3816
0x3fcaf4d8             mdns      1/1         352/3736
0x3fcb3a60        async_tcp      3/3        304/16064
0x3fc9c5dc        esp_timer    22/22         256/4340
0x3fca7430             wifi    23/23         304/6336

==================== THREAD 1 (TCB: 0x3fc9d9bc, name: 'tiT') =====================
#0  0x42094f46 in AsyncServer::_accept (this=0x0, pcb=0x3fcb5468, err=0 '\000') at .pio/libdeps/seeed_xiao_esp32c3_OTA/AsyncTCP/src/AsyncTCP.cpp:1296
#1  0x4203aaac in tcp_process (pcb=0x3fcb5468) at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/lwip/lwip/src/core/tcp_in.c:945
#2  tcp_input (p=p@entry=0x3fc9cc30, inp=inp@entry=0x3fca4bc0) at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/lwip/lwip/src/core/tcp_in.c:438
#3  0x4204075e in ip4_input (p=p@entry=0x3fc9cc30, inp=inp@entry=0x3fca4bc0) at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/lwip/lwip/src/core/ipv4/ip4.c:803
#4  0x42044eca in ethernet_input (p=0x3fc9cc30, netif=0x3fca4bc0) at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/lwip/lwip/src/netif/ethernet.c:186
#5  0x42033eca in tcpip_thread_handle_msg (msg=0x3fc9cc58) at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/lwip/lwip/src/api/tcpip.c:180
#6  tcpip_thread (arg=<optimized out>) at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/lwip/lwip/src/api/tcpip.c:154
#7  0x40389c90 in prvTaskExitError () at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/port/riscv/port.c:133
Backtrace stopped: frame did not save the PC

==================== THREAD 2 (TCB: 0x3fc9e6b8, name: 'IDLE') =====================
#0  0x420538da in esp_pm_impl_waiti () at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/esp_pm/pm_impl.c:849
#1  0x420255c0 in esp_vApplicationIdleHook () at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/esp_system/freertos_hooks.c:63
#2  0x40388726 in prvIdleTask (pvParameters=<optimized out>) at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/tasks.c:3987
#3  0x40389c90 in prvTaskExitError () at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/port/riscv/port.c:133
Backtrace stopped: frame did not save the PC

==================== THREAD 3 (TCB: 0x3fca0ebc, name: 'loopTask') =====================
#0  0x40389d62 in vPortYield () at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/port/riscv/port.c:327
#1  vPortYield () at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/port/riscv/port.c:310
#2  0x40389516 in vTaskDelay (xTicksToDelay=xTicksToDelay@entry=10) at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/tasks.c:1595
#3  0x420176fa in delay (ms=ms@entry=10) at C:/Users/SkowronLaptop/.platformio/packages/framework-arduinoespressif32/cores/esp32/esp32-hal-misc.c:178
#4  0x42005774 in loop () at src/main.cpp:90
#5  0x42017f3e in loopTask (pvParameters=<optimized out>) at C:/Users/SkowronLaptop/.platformio/packages/framework-arduinoespressif32/cores/esp32/main.cpp:50
#6  0x40389c90 in prvTaskExitError () at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/port/riscv/port.c:133
Backtrace stopped: frame did not save the PC

==================== THREAD 4 (TCB: 0x3fca3264, name: 'sys_evt') =====================
#0  0x40389d62 in vPortYield () at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/port/riscv/port.c:327
#1  vPortYield () at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/port/riscv/port.c:310
#2  0x4038806c in xQueueReceive (xQueue=0x3fca25f0, pvBuffer=pvBuffer@entry=0x3fca31d0, xTicksToWait=<optimized out>, xTicksToWait@entry=4294967295) at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/queue.c:1487
#3  0x420b7704 in esp_event_loop_run (event_loop=event_loop@entry=0x3fc9dc9c, ticks_to_run=ticks_to_run@entry=4294967295) at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/esp_event/esp_event.c:566
#4  0x420b78a6 in esp_event_loop_run_task (args=0x3fc9dc9c) at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/esp_event/esp_event.c:115
#5  0x40389c90 in prvTaskExitError () at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/port/riscv/port.c:133
Backtrace stopped: frame did not save the PC

==================== THREAD 5 (TCB: 0x3fca43d8, name: 'arduino_events') =====================
#0  0x40389d62 in vPortYield () at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/port/riscv/port.c:327
#1  vPortYield () at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/port/riscv/port.c:310
#2  0x4038806c in xQueueReceive (xQueue=0x3fc9dbb8, pvBuffer=pvBuffer@entry=0x3fca438c, xTicksToWait=<optimized out>, xTicksToWait@entry=4294967295) at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/queue.c:1487
#3  0x42009d3a in _arduino_event_task (arg=<optimized out>) at C:/Users/SkowronLaptop/.platformio/packages/framework-arduinoespressif32/libraries/WiFi/src/WiFiGeneric.cpp:304
#4  0x40389c90 in prvTaskExitError () at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/port/riscv/port.c:133
Backtrace stopped: frame did not save the PC

==================== THREAD 6 (TCB: 0x3fcaf4d8, name: 'mdns') =====================
#0  0x40389d62 in vPortYield () at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/port/riscv/port.c:327
#1  vPortYield () at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/port/riscv/port.c:310
#2  0x4038806c in xQueueReceive (xQueue=0x3fcadfb4, pvBuffer=pvBuffer@entry=0x3fcaf450, xTicksToWait=<optimized out>, xTicksToWait@entry=4294967295) at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/queue.c:1487
#3  0x4209eb32 in _mdns_service_task (pvParameters=<optimized out>) at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/mdns/mdns.c:4639
#4  0x40389c90 in prvTaskExitError () at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/port/riscv/port.c:133
Backtrace stopped: frame did not save the PC

==================== THREAD 7 (TCB: 0x3fcb3a60, name: 'async_tcp') =====================
#0  0x40389d62 in vPortYield () at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/port/riscv/port.c:327
#1  vPortYield () at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/port/riscv/port.c:310
#2  0x4038806c in xQueueReceive (xQueue=0x3fcaf96c, pvBuffer=pvBuffer@entry=0x3fcb39e4, xTicksToWait=<optimized out>, xTicksToWait@entry=4294967295) at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/queue.c:1487
#3  0x4209543c in _get_async_event (e=0x3fcb39e4) at .pio/libdeps/seeed_xiao_esp32c3_OTA/AsyncTCP/src/AsyncTCP.cpp:115
#4  _async_service_task (pvParameters=<optimized out>) at .pio/libdeps/seeed_xiao_esp32c3_OTA/AsyncTCP/src/AsyncTCP.cpp:188
#5  0x40389c90 in prvTaskExitError () at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/port/riscv/port.c:133
Backtrace stopped: frame did not save the PC

==================== THREAD 8 (TCB: 0x3fc9c5dc, name: 'esp_timer') =====================
#0  0x40389cfe in vPortClearInterruptMask (mask=1) at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/port/riscv/port.c:308
#1  0x40389d1e in vPortExitCritical () at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/port/riscv/port.c:259
#2  0x4038998a in ulTaskGenericNotifyTake (uxIndexToWait=uxIndexToWait@entry=0, xClearCountOnExit=xClearCountOnExit@entry=1, xTicksToWait=xTicksToWait@entry=4294967295) at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/tasks.c:5401
#3  0x4204ab8e in timer_task (arg=<optimized out>) at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/esp_timer/src/esp_timer.c:420
#4  0x40389c90 in prvTaskExitError () at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/port/riscv/port.c:133
Backtrace stopped: frame did not save the PC

==================== THREAD 9 (TCB: 0x3fca7430, name: 'wifi') =====================
#0  0x40389d62 in vPortYield () at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/port/riscv/port.c:327
#1  vPortYield () at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/port/riscv/port.c:310
#2  0x4038806c in xQueueReceive (xQueue=0x3fca5318, pvBuffer=0x3fca73b8, xTicksToWait=<optimized out>) at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/queue.c:1487
#3  0x400407be in ?? ()

======================= ALL MEMORY REGIONS ========================
Name   Address   Size   Attrs
.rtc.force_fast 0x50000010 0x0 RW
.rtc.force_slow 0x50000020 0x0 RW
.iram0.text 0x40380000 0xdd2e R XA
.dram0.data 0x3fc8de00 0x3b8c RW A
.noinit 0x3fc9198c 0x0 RW
.flash.text 0x42000020 0xb8f76 R XA
.flash.appdesc 0x3c0c0020 0x100 R  A
.flash.rodata 0x3c0c0120 0x2ece8 RW A
.eh_frame 0x3c0eee08 0xbcd8 R  A
.iram0.data 0x4038de00 0x0 RW
.iram0.bss 0x4038de00 0x0 RW
.coredump.tasks.data 0x3fc9d9bc 0x154 RW
.coredump.tasks.data 0x3fc9d7d0 0x1d0 RW
.coredump.tasks.data 0x3fc9e6b8 0x154 RW
.coredump.tasks.data 0x3fc9e5e0 0xc0 RW
.coredump.tasks.data 0x3fca0ebc 0x154 RW
.coredump.tasks.data 0x3fca0de0 0xc0 RW
.coredump.tasks.data 0x3fca3264 0x154 RW
.coredump.tasks.data 0x3fca3100 0x150 RW
.coredump.tasks.data 0x3fca43d8 0x154 RW
.coredump.tasks.data 0x3fca42b0 0x110 RW
.coredump.tasks.data 0x3fcaf4d8 0x154 RW
.coredump.tasks.data 0x3fcaf360 0x160 RW
.coredump.tasks.data 0x3fcb3a60 0x154 RW
.coredump.tasks.data 0x3fcb3910 0x130 RW
.coredump.tasks.data 0x3fc9c5dc 0x154 RW
.coredump.tasks.data 0x3fc9c4c0 0x100 RW
.coredump.tasks.data 0x3fca7430 0x154 RW
.coredump.tasks.data 0x3fca72e0 0x130 RW

===================== ESP32 CORE DUMP END =====================
===============================================================
Exception in thread Thread-1 (_readerthread):
Traceback (most recent call last):
  File "threading.py", line 1038, in _bootstrap_inner
Exception in thread Thread-2 (_readerthread):
Traceback (most recent call last):
  File "threading.py", line 1038, in _bootstrap_inner
  File "threading.py", line 975, in run
  File "threading.py", line 975, in run
  File "subprocess.py", line 1552, in _readerthread
  File "subprocess.py", line 1552, in _readerthread
OSError: [Errno 22] Invalid argument
OSError: [Errno 22] Invalid argument
Done!

Other Steps to Reproduce

I don't even know how i produced this.

I have checked existing issues, online documentation and the Troubleshooting Guide

me-no-dev commented 6 months ago

This is not the AsyncTCP repo and I'll try to fix it once 3.0.0 is final

skowron0 commented 6 months ago

OK thank you for your answer. If you have any suggestions, you can tell me, I'll be happy to test them.