me-no-dev / ESPAsyncWebServer

Async Web Server for ESP8266 and ESP32
3.71k stars 1.21k forks source link

ESP8266 crashing on safari ( ios or macos ) page request for link in same window #1198

Open flipoidix opened 2 years ago

flipoidix commented 2 years ago

Hello,

When a page with websockets active has a link for another page that needs to establish another websocket connection and the target is the same, ESP crashes.

If the link has target="blank" , this does not occur.

( you might need to try clicking 2 or 3 times in a row to make it happen )

tested on a ESP01 and on NodeMCU (ESP-12E)

I have this simplified code so that it is possible to replicate this bug. This only happens using safari ( ios or macos ) , Chrome is fine.

` // Import required libraries

include

include

include

//#include "FS.h" // SPIFFS

// Replace with your network credentials const char ssid = "YOURSSID"; const char password = "YOUR PASSWORD";

// Create AsyncWebServer object on port 80 AsyncWebServer server(80); AsyncWebSocket ws("/ws");

void onEvent(AsyncWebSocket server, AsyncWebSocketClient client, AwsEventType type, void arg, uint8_t data, size_t len) { switch (type) { case WS_EVT_CONNECT: Serial.printf("WebSocket client #%u connected from %s\n", client->id(), client->remoteIP().toString().c_str()); break; case WS_EVT_DISCONNECT: Serial.printf("WebSocket client #%u disconnected\n", client->id()); break; case WS_EVT_DATA: Serial.printf("message incoming"); break; case WS_EVT_PONG: break; case WS_EVT_ERROR: break; } }

const char page1_html[] PROGMEM = R"rawliteral( <!DOCTYPE HTML>

TESTPAGE1

LINK TO 2 - CRASHES

LINK TO 2 - FINE

)rawliteral";

const char page2_html[] PROGMEM = R"rawliteral( <!DOCTYPE HTML>

TESTPAGE2

LINK TO 1 - CRASHES

LINK TO 1 - FINE

)rawliteral";

void setup(){ // Serial port for debugging purposes Serial.begin(115200);

SPIFFS.begin();

// Connect to Wi-Fi WiFi.begin(ssid, password); while (WiFi.status() != WL_CONNECTED) { Serial.println("Connecting to WiFi.."); }

// Print ESP Local IP Address Serial.println(WiFi.localIP());

ws.onEvent(onEvent); server.addHandler(&ws);

//server.serveStatic("/", SPIFFS, "/").setDefaultFile("page1.html");

// Route for index server.on("/page1", HTTP_GET, [](AsyncWebServerRequest *request){ request->send_P(200, "text/html", page1_html); //request->send(SPIFFS, "/page1.html"); });

// Route for menu

server.on("/page2", HTTP_GET, [](AsyncWebServerRequest *request){ request->send_P(200, "text/html", page2_html); //request->send(SPIFFS, "/page2.html"); });

// Start server server.begin(); }

void loop() { ws.cleanupClients();

}

`

CRASH DECODED DATA IS :

`

Exception 28: LoadProhibited: A load referenced a page mapped with an attribute that does not permit loads PC: 0x40224163: tcp_free_acked_segments at core/tcp_in.c line 1125 EXCVADDR: 0x00000005

Decoding stack results 0x40207714: std::_Function_handler >::_M_invoke(const std::_Any_data &, void &&, AsyncClient &&) at /Users/link/Documents/Arduino/libraries/ESPAsyncWebServer-master/src/WebServer.cpp line 46 0x401000f1: std::function ::operator()(void, AsyncClient) const at /Users/link/Library/Arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/3.0.4-gcc10.3-1757bed/xtensa-lx106-elf/include/c++/10.3.0/bits/std_function.h line 617 0x40224375: tcp_receive at core/tcp_in.c line 1287 0x40225576: tcp_input at core/tcp_in.c line 956 0x40223031: ip4_input at core/ipv4/ip4.c line 1467 0x40100847: umm_free_core(umm_heap_context_t, void) at /Users/link/Library/Arduino15/packages/esp8266/hardware/esp8266/3.0.2/cores/esp8266/umm_malloc/umm_malloc.cpp line 549 0x4021bd39: ethernet_input_LWIP2 at netif/ethernet.c line 188 0x4021bb38: esp2glue_ethernet_input at glue-lwip/lwip-git.c line 116 0x40244469: ethernet_input at glue-esp/lwip-esp.c line 365 0x4024447b: ethernet_input at glue-esp/lwip-esp.c line 373 0x40100a00: umm_init() at /Users/link/Library/Arduino15/packages/esp8266/hardware/esp8266/3.0.2/cores/esp8266/umm_malloc/umm_malloc.cpp line 476 0x401000ac: app_entry_redefinable() at /Users/link/Library/Arduino15/packages/esp8266/hardware/esp8266/3.0.2/cores/esp8266/core_esp8266_main.cpp line 325 0x4021bb90: esp2glue_netif_set_up1down0 at glue-lwip/lwip-git.c line 493 0x4021bc88: esp2glue_netif_update at glue-lwip/lwip-git.c line 418 0x40100278: ets_post(uint8, ETSSignal, ETSParam) at /Users/link/Library/Arduino15/packages/esp8266/hardware/esp8266/3.0.2/cores/esp8266/core_esp8266_main.cpp line 181 0x40100278: ets_post(uint8, ETSSignal, ETSParam) at /Users/link/Library/Arduino15/packages/esp8266/hardware/esp8266/3.0.2/cores/esp8266/core_esp8266_main.cpp line 181 0x40100278: ets_post(uint8, ETSSignal, ETSParam) at /Users/link/Library/Arduino15/packages/esp8266/hardware/esp8266/3.0.2/cores/esp8266/core_esp8266_main.cpp line 181 0x40100278: ets_post(uint8, ETSSignal, ETSParam) at /Users/link/Library/Arduino15/packages/esp8266/hardware/esp8266/3.0.2/cores/esp8266/core_esp8266_main.cpp line 181 0x40100278: ets_post(uint8, ETSSignal, ETSParam) at /Users/link/Library/Arduino15/packages/esp8266/hardware/esp8266/3.0.2/cores/esp8266/core_esp8266_main.cpp line 181 0x40100278: ets_post(uint8, ETSSignal, ETSParam) at /Users/link/Library/Arduino15/packages/esp8266/hardware/esp8266/3.0.2/cores/esp8266/core_esp8266_main.cpp line 181 0x40208629: serialEventRun() at /Users/link/Library/Arduino15/packages/esp8266/hardware/esp8266/3.0.2/cores/esp8266/HardwareSerial.cpp line 174 0x40209f54: loop_wrapper() at /Users/link/Library/Arduino15/packages/esp8266/hardware/esp8266/3.0.2/cores/esp8266/core_esp8266_main.cpp line 205 0x4021cbbf: tcp_listen_with_backlog at core/tcp.c line 828 0x40201ab5: AsyncServer::begin() at /Users/link/Documents/Arduino/libraries/ESPAsyncTCP-master/src/ESPAsyncTCP.cpp line 1131 0x40209c77: operator new(unsigned int) at /Users/link/Library/Arduino15/packages/esp8266/hardware/esp8266/3.0.2/cores/esp8266/abi.cpp line 41 0x40207ab9: AsyncWebServer::begin() at /Users/link/Documents/Arduino/libraries/ESPAsyncWebServer-master/src/WebServer.cpp line 84 0x4020366e: AsyncWebSocket::count() const at /Users/link/Library/Arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/3.0.4-gcc10.3-1757bed/xtensa-lx106-elf/include/c++/10.3.0/bits/std_function.h line 303 0x40213968: std::_Function_handler >::_M_manager(std::_Any_data &, const std::_Any_data &, std::_Manager_operation) at /Users/link/Library/Arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/3.0.4-gcc10.3-1757bed/xtensa-lx106-elf/include/c++/10.3.0/bits/std_function.h line 268 0x40213958: std::_Function_handler >::_M_invoke(const std::_Any_data &, AsyncWebSocketClient * const&) at /Users/link/Documents/Arduino/libraries/ESPAsyncWebServer-master/src/AsyncWebSocket.h line 185 0x40100278: ets_post(uint8, ETSSignal, ETSParam) at /Users/link/Library/Arduino15/packages/esp8266/hardware/esp8266/3.0.2/cores/esp8266/core_esp8266_main.cpp line 181 0x40100299: esp_schedule() at /Users/link/Library/Arduino15/packages/esp8266/hardware/esp8266/3.0.2/cores/esp8266/core_esp8266_main.cpp line 128 0x40209f5a: loop_wrapper() at /Users/link/Library/Arduino15/packages/esp8266/hardware/esp8266/3.0.2/cores/esp8266/core_esp8266_main.cpp line 205

`

teknoel commented 2 years ago

https://github.com/me-no-dev/ESPAsyncWebServer/issues/1201

stale[bot] commented 1 year ago

[STALE_SET] This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. Thank you for your contributions.

teknoel commented 1 year ago

This is still unresolved

stale[bot] commented 1 year ago

[STALE_CLR] This issue has been removed from the stale queue. Please ensure activity to keep it openin the future.

stale[bot] commented 1 year ago

[STALE_SET] This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. Thank you for your contributions.