Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

MDNS special packet from Android App crashes and reboots ESP32/ESP32-S2 #6368

Copy link
Copy link
Closed
@avillacis

Description

@avillacis
Issue body actions

Board

ESP32, ESP32-S2

Device Description

Issue reproduced on both YUBOX Node (ESP32) and YUBOX One (ESP32-S2)

Hardware Configuration

ESP32 board has inbuilt I2C sensors, otherwise plain
ESP32-S2 board has buzzer and I2C sensors on different pins

Version

v2.0.2

IDE Name

Arduino IDE 1.8.19

Operating System

Android 8.x, Android 9

Flash frequency

80 MHz

PSRAM enabled

no

Upload speed

115200

Description

I downloaded an Android App to perform MDNS discovery of various ESP32 and ESP32-S2 devices connected to a local network. The Android App is Service Browser by Andriy Druk. This is the link to the Google Play Store.

My YUBOX Framework projects enable MDNS and expose _http._tcp as a MDNS service in order to be discoverable. With other OS such as Fedora Linux and Windows, all runs OK. However, when using the app, and choosing the _http._tcp section, then the specific ESP32 name exposed by the device, the device itself crashes and reboots.

The below sketch also reproduces this bug. It is a straightforward copy of the MDNS HTTP server example provided by Arduino-ESP32, except with my WiFi credentials, and the MDNS name changed to esp32-crashme.

The expected behavior is, obviously, no crash.

Sketch

#include <Arduino.h>
#include <WiFi.h>
#include <ESPmDNS.h>


static const char * ssid = ".....";
static const char * password = ".....";

// TCP server at port 80 will respond to HTTP requests
WiFiServer server(80);

void setup()
{
    Serial.begin(115200);

    // Connect to WiFi network
    WiFi.begin(ssid, password);
    Serial.println("");

    // Wait for connection
    while (WiFi.status() != WL_CONNECTED) {
        delay(500);
        Serial.print(".");
    }
    Serial.println("");
    Serial.print("Connected to ");
    Serial.println(ssid);
    Serial.print("IP address: ");
    Serial.println(WiFi.localIP());

    // Set up mDNS responder:
    // - first argument is the domain name, in this example
    //   the fully-qualified domain name is "esp32.local"
    // - second argument is the IP address to advertise
    //   we send our IP address on the WiFi network
    if (!MDNS.begin("esp32-crashme")) {
        Serial.println("Error setting up MDNS responder!");
        while(1) {
            delay(1000);
        }
    }
    Serial.println("mDNS responder started");

    // Start TCP (HTTP) server
    server.begin();
    Serial.println("TCP server started");

    // Add service to MDNS-SD
    MDNS.addService("http", "tcp", 80);
}

void loop()
{
    // Check if a client has connected
    WiFiClient client = server.available();
    if (!client) {
        return;
    }
    Serial.println("");
    Serial.println("New client");

    // Wait for data from client to become available
    while(client.connected() && !client.available()){
        delay(1);
    }

    // Read the first line of HTTP request
    String req = client.readStringUntil('\r');

    // First line of HTTP request looks like "GET /path HTTP/1.1"
    // Retrieve the "/path" part by finding the spaces
    int addr_start = req.indexOf(' ');
    int addr_end = req.indexOf(' ', addr_start + 1);
    if (addr_start == -1 || addr_end == -1) {
        Serial.print("Invalid request: ");
        Serial.println(req);
        return;
    }
    req = req.substring(addr_start + 1, addr_end);
    Serial.print("Request: ");
    Serial.println(req);

    String s;
    if (req == "/")
    {
        IPAddress ip = WiFi.localIP();
        String ipStr = String(ip[0]) + '.' + String(ip[1]) + '.' + String(ip[2]) + '.' + String(ip[3]);
        s = "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\n<!DOCTYPE HTML>\r\n<html>Hello from ESP32 at ";
        s += ipStr;
        s += "</html>\r\n\r\n";
        Serial.println("Sending 200");
    }
    else
    {
        s = "HTTP/1.1 404 Not Found\r\n\r\n";
        Serial.println("Sending 404");
    }
    client.print(s);

    client.stop();
    Serial.println("Done with client");
}

Debug Message

rst:0x1 (POWERON_RESET),boot:0x17 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0030,len:1324
ho 0 tail 12 room 4
load:0x40078000,len:13508
load:0x40080400,len:3604
entry 0x400805f0
[     1][V][WiFiServer.h:42] WiFiServer(): WiFiS�␘����:WiFiServer(port=80, ...)
[     2][D][esp32-hal-cpu.c:211] setCpuFrequencyMhz(): PLL: 480 / 2 = 240 Mhz, APB: 80000000 Hz
[    60][D][WiFiGeneric.cpp:831] _eventCallback(): Arduino Event: 0 - WIFI_READY
[   148][V][WiFiGeneric.cpp:272] _arduino_event_cb(): STA Started
[   149][V][WiFiGeneric.cpp:96] set_esp_interface_ip(): Configuring Station static IP: 0.0.0.0, MASK: 0.0.0.0, GW: 0.0.0.0
[   150][D][WiFiGeneric.cpp:831] _eventCallback(): Arduino Event: 2 - STA_START

....[  2425][V][WiFiGeneric.cpp:284] _arduino_event_cb(): STA Connected: SSID: PSW-DEVICES, BSSID: 46:d9:e7:b7:1a:c2, Channel: 1, Auth: WPA2_PSK
[  2426][D][WiFiGeneric.cpp:831] _eventCallback(): Arduino Event: 4 - STA_CONNECTED
[  2554][V][WiFiGeneric.cpp:294] _arduino_event_cb(): STA Got New IP:172.16.238.40
[  2554][D][WiFiGeneric.cpp:831] _eventCallback(): Arduino Event: 7 - STA_GOT_IP
[  2557][D][WiFiGeneric.cpp:880] _eventCallback(): STA IP: 172.16.238.40, MASK: 255.255.240.0, GW: 172.16.224.1
.
Connected to PSW-DEVICES
IP address: 172.16.238.40
mDNS responder started
TCP server started
Guru Meditation Error: Core  0 panic'ed (LoadProhibited). Exception was unhandled.

Core  0 register dump:
PC      : 0x4008941f  PS      : 0x00060630  A0      : 0x800fb8d7  A1      : 0x3ffcc020  
A2      : 0x3ffcac90  A3      : 0x00000000  A4      : 0x00000018  A5      : 0x3ffcc3a8  
A6      : 0x00000000  A7      : 0x00000000  A8      : 0x0000005f  A9      : 0x00000000  
A10     : 0x00000000  A11     : 0x3ffc4bb2  A12     : 0x3ff96355  A13     : 0x3ffc4b36  
A14     : 0x0000006c  A15     : 0x00000000  SAR     : 0x00000004  EXCCAUSE: 0x0000001c  
EXCVADDR: 0x00000000  LBEG    : 0x40089078  LEND    : 0x4008908e  LCOUNT  : 0x00000000  


Backtrace:0x4008941c:0x3ffcc0200x400fb8d4:0x3ffcc040 0x400ff6c1:0x3ffcc070 0x40100361:0x3ffcc140 

----------
PC: 0x4008941f: strcasecmp at /builds/idf/crosstool-NG/.build/xtensa-esp32-elf/src/newlib/newlib/libc/string/strcasecmp.c line 46
EXCVADDR: 0x00000000

Decoding stack results
0x4008941c: strcasecmp at /builds/idf/crosstool-NG/.build/xtensa-esp32-elf/src/newlib/newlib/libc/string/strcasecmp.c line 46
0x400fb8d4: _mdns_get_service_item_instance at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/mdns/mdns.c line 265
0x400ff6c1: mdns_parse_packet at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/mdns/mdns.c line 1461
0x40100361: _mdns_service_task at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/mdns/mdns.c line 4460

Other Steps to Reproduce

No response

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

  • I confirm I have checked existing issues, online documentation and Troubleshooting guide.

Metadata

Metadata

Assignees

Type

No type

Projects

Status

Done
Show more project fields

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.