esp8266 / Arduino

ESP8266 core for Arduino
GNU Lesser General Public License v2.1
16.07k stars 13.33k forks source link

No poison after block with current git version #8952

Closed hmueller01 closed 1 year ago

hmueller01 commented 1 year ago

Basic Infos

Platform

Settings in IDE

Problem Description

After connecting to the AP the module panics

add 1
aid 1
station: a4:83:e7:d2:34:b7 join, AID = 1
No poison after block at: 0xe5a4e455, actual data: 0x80 0x0 0x0 0x0

User exception (panic/abort/assert)
--------------- CUT HERE FOR EXCEPTION DECODER ---------------

Panic umm_malloc.cpp:751 umm_malloc_core

>>>stack>>>

Decoded stack dump see below.

The same code works well with Arduino Release 3.1.2.

MCVE Sketch

There is a lot of code I wrote, so it is not really possible to show it here. But showing the lines noted in the stack dump might help.

/Users/hmueller/src/PlatformIO/Projects/rhts-platformio/src/rhts-arduino.cpp:142 is a global definition of https://github.com/hmueller01/ESP_WiFiManager_Lite

ESP_WiFiManager_Lite m_wifi_manager;

0x4020dc73: ESP_WiFiManager_Lite::run() at /Users/hmueller/src/PlatformIO/Projects/rhts-platformio/lib/ESP_WiFiManager_Lite.hmueller01/src/ESP_WiFiManager_Lite.h:921

            if ( String(ARDUINO_BOARD) == "ESP32S2_DEV" )

ARDUINO_BOARD expands to "PLATFORMIO_SHELLY1"

So it looks like the new git platform doesn't like this. Or am I wrong? If you need more code details please let me know.

Debug Messages

Panic umm_malloc.cpp:751 umm_malloc_core
sp: 3ffffc80 end: 3fffffc0 offset: 0010

ctx: cont
0x3ffe8944: ?? at /Users/hmueller/.platformio/packages/framework-arduinoespressif8266@src-31d658a59f41540201fc3726a1394910/cores/esp8266/umm_malloc/umm_malloc.cpp:123
0x40101063: umm_malloc_core at /Users/hmueller/.platformio/packages/framework-arduinoespressif8266@src-31d658a59f41540201fc3726a1394910/cores/esp8266/umm_malloc/umm_malloc.cpp:751 (discriminator 1)
0x3ffe8944: ?? at /Users/hmueller/.platformio/packages/framework-arduinoespressif8266@src-31d658a59f41540201fc3726a1394910/cores/esp8266/umm_malloc/umm_malloc.cpp:123
0x40101050: umm_malloc_core at /Users/hmueller/.platformio/packages/framework-arduinoespressif8266@src-31d658a59f41540201fc3726a1394910/cores/esp8266/umm_malloc/umm_malloc.cpp:751
0x3ffe8944: ?? at /Users/hmueller/.platformio/packages/framework-arduinoespressif8266@src-31d658a59f41540201fc3726a1394910/cores/esp8266/umm_malloc/umm_malloc.cpp:123
0x40101381: umm_malloc at /Users/hmueller/.platformio/packages/framework-arduinoespressif8266@src-31d658a59f41540201fc3726a1394910/cores/esp8266/umm_malloc/umm_malloc.cpp:912
0x4010141c: umm_realloc at /Users/hmueller/.platformio/packages/framework-arduinoespressif8266@src-31d658a59f41540201fc3726a1394910/cores/esp8266/umm_malloc/umm_malloc.cpp:946
0x4010141c: umm_realloc at /Users/hmueller/.platformio/packages/framework-arduinoespressif8266@src-31d658a59f41540201fc3726a1394910/cores/esp8266/umm_malloc/umm_malloc.cpp:946
0x40100d54: get_poisoned at /Users/hmueller/.platformio/packages/framework-arduinoespressif8266@src-31d658a59f41540201fc3726a1394910/cores/esp8266/umm_malloc/umm_poison.c:121
(inlined by) get_poisoned at /Users/hmueller/.platformio/packages/framework-arduinoespressif8266@src-31d658a59f41540201fc3726a1394910/cores/esp8266/umm_malloc/umm_poison.c:109
0x40101386: umm_malloc at /Users/hmueller/.platformio/packages/framework-arduinoespressif8266@src-31d658a59f41540201fc3726a1394910/cores/esp8266/umm_malloc/umm_malloc.cpp:914
0x40101674: umm_poison_realloc_fl at /Users/hmueller/.platformio/packages/framework-arduinoespressif8266@src-31d658a59f41540201fc3726a1394910/cores/esp8266/umm_malloc/umm_local.c:152
0x40101674: umm_poison_realloc_fl at /Users/hmueller/.platformio/packages/framework-arduinoespressif8266@src-31d658a59f41540201fc3726a1394910/cores/esp8266/umm_malloc/umm_local.c:152
0x4010097c: realloc at /Users/hmueller/.platformio/packages/framework-arduinoespressif8266@src-31d658a59f41540201fc3726a1394910/cores/esp8266/heap.cpp:273
0x4021a05c: String::changeBuffer(unsigned int) at /Users/hmueller/.platformio/packages/framework-arduinoespressif8266@src-31d658a59f41540201fc3726a1394910/cores/esp8266/WString.cpp:246
0x40101674: umm_poison_realloc_fl at /Users/hmueller/.platformio/packages/framework-arduinoespressif8266@src-31d658a59f41540201fc3726a1394910/cores/esp8266/umm_malloc/umm_local.c:152
0x4021a117: String::reserve(unsigned int) at /Users/hmueller/.platformio/packages/framework-arduinoespressif8266@src-31d658a59f41540201fc3726a1394910/cores/esp8266/WString.cpp:192 (discriminator 4)
0x4021a478: String::concat(char const*, unsigned int) at /Users/hmueller/.platformio/packages/framework-arduinoespressif8266@src-31d658a59f41540201fc3726a1394910/cores/esp8266/WString.cpp:369
0x4021051c: ClientContext::_consume(unsigned int) at /Users/hmueller/.platformio/packages/framework-arduinoespressif8266@src-31d658a59f41540201fc3726a1394910/libraries/ESP8266WiFi/src/include/ClientContext.h:592
0x4021a5aa: String::concat(char) at /Users/hmueller/.platformio/packages/framework-arduinoespressif8266@src-31d658a59f41540201fc3726a1394910/cores/esp8266/WString.cpp:385
0x40218f00: Stream::timedRead() at /Users/hmueller/.platformio/packages/framework-arduinoespressif8266@src-31d658a59f41540201fc3726a1394910/cores/esp8266/Stream.cpp:35
0x40218fd5: Stream::readStringUntil(char) at /Users/hmueller/.platformio/packages/framework-arduinoespressif8266@src-31d658a59f41540201fc3726a1394910/cores/esp8266/Stream.cpp:260
0x4020a333: esp8266webserver::ESP8266WebServerTemplate<WiFiServer>::_parseRequest(WiFiClient&) at /Users/hmueller/.platformio/packages/framework-arduinoespressif8266@src-31d658a59f41540201fc3726a1394910/libraries/ESP8266WebServer/src/Parsing-impl.h:201
0x3ffefaac: _Pri_3_Stack at nmi-vector.o:?
0x3ffeffbc: _Pri_3_Stack at nmi-vector.o:?
0x4010141c: umm_realloc at /Users/hmueller/.platformio/packages/framework-arduinoespressif8266@src-31d658a59f41540201fc3726a1394910/cores/esp8266/umm_malloc/umm_malloc.cpp:946
0x3ffeffbc: _Pri_3_Stack at nmi-vector.o:?
0x40100ebd: check_poison_neighbors$part$0 at /Users/hmueller/.platformio/packages/framework-arduinoespressif8266@src-31d658a59f41540201fc3726a1394910/cores/esp8266/umm_malloc/umm_local.c:72
0x3ffe8944: ?? at /Users/hmueller/.platformio/packages/framework-arduinoespressif8266@src-31d658a59f41540201fc3726a1394910/cores/esp8266/umm_malloc/umm_malloc.cpp:123
0x3ffeffbc: _Pri_3_Stack at nmi-vector.o:?
0x3ffefaac: _Pri_3_Stack at nmi-vector.o:?
0x4020da3b: esp8266webserver::ESP8266WebServerTemplate<WiFiServer>::handleClient() at /Users/hmueller/.platformio/packages/framework-arduinoespressif8266@src-31d658a59f41540201fc3726a1394910/libraries/ESP8266WebServer/src/ESP8266WebServer-impl.h:340
0x4026fef2: wifi_get_opmode at /home/wchen/gwen/nonos/app/main/user_interface.c:1821
0x3ffef690: _Pri_3_Stack at /Users/hmueller/src/PlatformIO/Projects/rhts-platformio/src/rhts-arduino.cpp:142
0x3ffefbf4: _Pri_3_Stack at nmi-vector.o:?
0x4020f6d8: ESP8266WiFiSTAClass::status() at /Users/hmueller/.platformio/packages/framework-arduinoespressif8266@src-31d658a59f41540201fc3726a1394910/libraries/ESP8266WiFi/src/ESP8266WiFiSTA.cpp:556
0x3ffeffbc: _Pri_3_Stack at nmi-vector.o:?
0x3ffefaac: _Pri_3_Stack at nmi-vector.o:?
0x3ffefbf4: _Pri_3_Stack at nmi-vector.o:?
0x3ffef690: _Pri_3_Stack at /Users/hmueller/src/PlatformIO/Projects/rhts-platformio/src/rhts-arduino.cpp:142
0x4020dc73: ESP_WiFiManager_Lite::run() at /Users/hmueller/src/PlatformIO/Projects/rhts-platformio/lib/ESP_WiFiManager_Lite.hmueller01/src/ESP_WiFiManager_Lite.h:921
0x3ffefa84: _Pri_3_Stack at /Users/hmueller/src/PlatformIO/Projects/rhts-platformio/include/dynamicParams.h:51
0x3ffefa84: _Pri_3_Stack at /Users/hmueller/src/PlatformIO/Projects/rhts-platformio/include/dynamicParams.h:51
0x3ffef690: _Pri_3_Stack at /Users/hmueller/src/PlatformIO/Projects/rhts-platformio/src/rhts-arduino.cpp:142
0x40209130: wifiSetup() at /Users/hmueller/src/PlatformIO/Projects/rhts-platformio/src/rhts-arduino.cpp:338
0x40223ab0: std::_Function_handler<void (WiFiEventStationModeGotIP const&), wifiSetup()::{lambda(WiFiEventStationModeGotIP const&)#1}>::_M_manager(std::_Any_data&, std::_Function_handler<void (WiFiEventStationModeGotIP const&), wifiSetup()::{lambda(WiFiEventStationModeGotIP const&)#1}> const&, std::_Manager_operation) at /Users/hmueller/.platformio/packages/toolchain-xtensa/xtensa-lx106-elf/include/c++/10.3.0/bits/std_function.h:271
0x3ffeffbc: _Pri_3_Stack at nmi-vector.o:?
0x3ffef690: _Pri_3_Stack at /Users/hmueller/src/PlatformIO/Projects/rhts-platformio/src/rhts-arduino.cpp:142
0x4020de00: loop at /Users/hmueller/src/PlatformIO/Projects/rhts-platformio/src/rhts-arduino.cpp:1427
0x3ffefd4c: _Pri_3_Stack at nmi-vector.o:?
0x3ffefdb0: _Pri_3_Stack at nmi-vector.o:?
0x402188fc: Print::print(char const*) at /Users/hmueller/.platformio/packages/framework-arduinoespressif8266@src-31d658a59f41540201fc3726a1394910/cores/esp8266/Print.cpp:122
0x3ffef690: _Pri_3_Stack at /Users/hmueller/src/PlatformIO/Projects/rhts-platformio/src/rhts-arduino.cpp:142
0x3ffefd4c: _Pri_3_Stack at nmi-vector.o:?
0x3ffefdb0: _Pri_3_Stack at nmi-vector.o:?
0x402092e1: setup at /Users/hmueller/src/PlatformIO/Projects/rhts-platformio/src/rhts-arduino.cpp:1402
0x40100470: ets_post at /Users/hmueller/.platformio/packages/framework-arduinoespressif8266@src-31d658a59f41540201fc3726a1394910/cores/esp8266/core_esp8266_main.cpp:238
0x3ffeff90: _Pri_3_Stack at nmi-vector.o:?
0x40100491: esp_schedule at /Users/hmueller/.platformio/packages/framework-arduinoespressif8266@src-31d658a59f41540201fc3726a1394910/cores/esp8266/core_esp8266_main.cpp:136
0x3ffeff90: _Pri_3_Stack at nmi-vector.o:?
0x4021b608: loop_wrapper() at /Users/hmueller/.platformio/packages/framework-arduinoespressif8266@src-31d658a59f41540201fc3726a1394910/cores/esp8266/core_esp8266_main.cpp:258
0x401003c9: cont_wrapper at ??:?
mhightower83 commented 1 year ago

@hmueller01 I see the bug. I should have a PR later today or tomorrow.

For an MCVE the "CaptivePortal" example shows the issue, after adding Serial.begin. (Serial.begin makes the stack trace visible.)

#include <ESP8266WiFi.h>
#include <DNSServer.h>
#include <ESP8266WebServer.h>

const byte DNS_PORT = 53;
IPAddress apIP(172, 217, 28, 1);
DNSServer dnsServer;
ESP8266WebServer webServer(80);

String responseHTML = ""
                      "<!DOCTYPE html><html lang='en'><head>"
                      "<meta name='viewport' content='width=device-width'>"
                      "<title>CaptivePortal</title></head><body>"
                      "<h1>Hello World!</h1><p>This is a captive portal example."
                      " All requests will be redirected here.</p></body></html>";

void setup() {
  Serial.begin(115200);
  delay(200);
  Serial.printf("\r\n\r\nDNSServer CaptivePortal example\r\n");

  WiFi.mode(WIFI_AP);
  WiFi.softAPConfig(apIP, apIP, IPAddress(255, 255, 255, 0));
  WiFi.softAP("DNSServer CaptivePortal example");

  // if DNSServer is started with "*" for domain name, it will reply with
  // provided IP to all DNS request
  dnsServer.start(DNS_PORT, "*", apIP);

  // replay to all requests with same HTML
  webServer.onNotFound([]() {
    webServer.send(200, "text/html", responseHTML);
  });
  webServer.begin();
}

void loop() {
  dnsServer.processNextRequest();
  webServer.handleClient();
}
hmueller01 commented 1 year ago

I will check your PR. But it might take a few days. Thanks for the quick solution!

hmueller01 commented 1 year ago

Ok, checked your PR. It fixes all my problems (had panics at lots of locations in my code). Thanks a lot!!! What a simple thing that costs me hours of debugging my code (as I thought I did something wrong or running out of memory). Please bring this to develop asap as it might fix problems for other users too.