From 0450e61738fee0ad0f4d07478b566e8667c55d93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Doanh=20V=C4=83n=20L=C6=B0=C6=A1ng?= Date: Wed, 25 Jul 2018 02:01:44 +0700 Subject: [PATCH] Fix call to tcp_recved after pcb has been closed (#75) I got exception 28 with this decode ``` Exception 28: LoadProhibited: A load referenced a page mapped with an attribute that does not permit loads Decoding 27 results 0x4022b043: tcp_recved at /home/david/dev/esp8266/origin/tools/sdk/lwip2/builder/lwip2-src/src/core/tcp.c line 1690 0x40202757: uart_write_char at C:\Users\doanh\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.4.0\cores\esp8266/uart.c line 464 0x40247e81: scan_parse_beacon at ?? line ? 0x402120b0: AsyncMqttClient::_sendDisconnect() at D:\Documents\Arduino\libraries\async-mqtt-client-master\src/AsyncMqttClient.cpp line 96 0x4021213d: AsyncMqttClient::disconnect(bool) at D:\Documents\Arduino\libraries\async-mqtt-client-master\src/AsyncMqttClient.cpp line 96 0x4010502c: ets_timer_arm_new at ?? line ? 0x4021353d: AsyncMqttClient::_onPoll(AsyncClient*) at D:\Documents\Arduino\libraries\async-mqtt-client-master\src/AsyncMqttClient.cpp line 96 0x40213574: _M_invoke at D:\Documents\Arduino\libraries\async-mqtt-client-master\src/AsyncMqttClient.cpp line 96 0x4021444e: std::function ::operator()(void*, AsyncClient*) const at D:\Documents\Arduino\libraries\ESPAsyncTCP-master\src/ESPAsyncTCP.cpp line 659 0x402149b0: AsyncClient::_poll(tcp_pcb*) at D:\Documents\Arduino\libraries\ESPAsyncTCP-master\src/ESPAsyncTCP.cpp line 659 0x402149c4: AsyncClient::_s_poll(void*, tcp_pcb*) at D:\Documents\Arduino\libraries\ESPAsyncTCP-master\src/ESPAsyncTCP.cpp line 659 0x4022b3c8: tcp_slowtmr at /home/david/dev/esp8266/origin/tools/sdk/lwip2/builder/lwip2-src/src/core/tcp.c line 1690 0x4022b768: tcp_fasttmr at /home/david/dev/esp8266/origin/tools/sdk/lwip2/builder/lwip2-src/src/core/tcp.c line 1690 0x4022bcb4: tcpip_tcp_timer at /home/david/dev/esp8266/origin/tools/sdk/lwip2/builder/lwip2-src/src/core/timeouts.c line 126 0x4022bcb4: tcpip_tcp_timer at /home/david/dev/esp8266/origin/tools/sdk/lwip2/builder/lwip2-src/src/core/timeouts.c line 126 0x4022b7ac: tcp_tmr at /home/david/dev/esp8266/origin/tools/sdk/lwip2/builder/lwip2-src/src/core/tcp.c line 1690 0x4022bd38: cyclic_timer at /home/david/dev/esp8266/origin/tools/sdk/lwip2/builder/lwip2-src/src/core/timeouts.c line 165 0x4022bcbc: tcpip_tcp_timer at /home/david/dev/esp8266/origin/tools/sdk/lwip2/builder/lwip2-src/src/core/timeouts.c line 132 0x40104d9e: wdt_feed at ?? line ? 0x4022be04: sys_check_timeouts at /home/david/dev/esp8266/origin/tools/sdk/lwip2/builder/lwip2-src/src/core/timeouts.c line 351 0x4025f100: ets_timer_handler_isr at ?? line ? 0x4025f10d: ets_timer_handler_isr at ?? line ? 0x4025f152: ets_timer_handler_isr at ?? line ? 0x4021d267: loop_task at C:\Users\doanh\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.4.0\cores\esp8266/core_esp8266_main.cpp line 132 ``` so this fix can resolve this error --- src/ESPAsyncTCP.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/ESPAsyncTCP.cpp b/src/ESPAsyncTCP.cpp index 801d2ce..d6f78d7 100644 --- a/src/ESPAsyncTCP.cpp +++ b/src/ESPAsyncTCP.cpp @@ -201,7 +201,8 @@ int8_t AsyncClient::abort(){ } void AsyncClient::close(bool now){ - tcp_recved(_pcb, _rx_ack_len); + if(_pcb) + tcp_recved(_pcb, _rx_ack_len); if(now) _close(); else