ESP8266 Stack error - Panic umm_malloc

Hi,

I am getting the below stack exception in some scenarios when i load a html page - it would be great if somehow has encountered similar error in the past



Panic umm_malloc.cpp:229 umm_get_ptr_context

>>>stack>>>

ctx: cont
sp: 3ffffc60 end: 3fffffc0 offset: 0000
3ffffc60:  4010271d 3fff2c94 3ffffd10 00000007  
3ffffc70:  000000fe 00000000 00000000 00000000  
3ffffc80:  00000000 00000000 00000000 3fff00a4  
3ffffc90:  3fff0838 00000006 3ffffddc 3ffefc70  
3ffffca0:  3ffefc58 00000020 ffffffff 4021e5be  
3ffffcb0:  3ffffcd0 00000001 3ffffddc 4021e62b  
3ffffcc0:  3ffefc58 00000020 3fff1644 40100c74  
3ffffcd0:  3ffefc58 3ffefc40 3ffefc40 40100d75  
3ffffce0:  3ffefc58 3ffefc4c 3ffffd20 4021c7c1  
3ffffcf0:  3ffe9aef 3ffefc4c 3ffffd10 402016d9  
3ffffd00:  3ffefc58 3ffefc4c 3ffe9aef 40205916  
3ffffd10:  008e0000 ffffffff ffffffff ffffffff  
3ffffd20:  ffffffff ffffffff ffffffff ffffffff  
3ffffd30:  bf58ffff 83c44725 ffff0281 002716f8  
3ffffd40:  00000000 00000000 00000000 00000000  
3ffffd50:  008e0000 ffffffff ffffffff ffffffff  
3ffffd60:  ffffffff ffffffff ffffffff ffffffff  
3ffffd70:  bf58ffff 83c44725 ffff0281 002716f8  
3ffffd80:  00000000 00000000 00000000 00000000  
3ffffd90:  008e0000 ffffffff ffffffff ffffffff  
3ffffda0:  ffffffff ffffffff ffffffff ffffffff  
3ffffdb0:  bf58ffff 83c44725 ffff0281 002716f8  
3ffffdc0:  00000000 00000000 00000000 00000000  
3ffffdd0:  00000000 0023002f 00000000 00000000  
3ffffde0:  0023002f 00000000 00000000 001c001f  
3ffffdf0:  00000000 00000000 001b001f 00000000  
3ffffe00:  00000000 001a001f 00000000 00000000  
3ffffe10:  0019001f 00000000 00000000 0015001f  
3ffffe20:  00000000 00000000 0014001f 00000000  
3ffffe30:  00000000 0010001f 00000000 00000000  
3ffffe40:  000f000f 00000000 00000000 000c000f  
3ffffe50:  00000000 00000000 000b000f 00000000  
3ffffe60:  00000000 00000000 00000000 00000000  
3ffffe70:  3ffef83c 00000000 00000000 402091c0  
3ffffe80:  00000000 00000000 00000000 00000000  
3ffffe90:  00000000 00000000 00000000 00000000  
3ffffea0:  3ffefc94 3ffefc88 3ffefc7c 4021d154  
3ffffeb0:  00000000 4bc6a7f0 55810624 3fff0058  
3ffffec0:  3fffdad0 00000001 3fff1cc4 40223932  
3ffffed0:  00000708 00000000 00000000 401000e9  
3ffffee0:  00000000 00000000 3fff2c94 40204e01  
3ffffef0:  00000000 3ffef860 3ffef818 402099ac  
3fffff00:  00000000 00000000 00000000 69746365  
3fffff10:  00000000 3ffefdf8 40100629 00000000  
3fffff20:  0002d218 00000000 00000000 00000001  
3fffff30:  00000000 00000000 3ffef818 3fff0058  
3fffff40:  3fffdad0 3ffef83c 3ffef818 4020a57e  
3fffff50:  40224da8 00000000 00001388 4021ab00  
3fffff60:  00000000 00000000 3fff331c 00000000  
3fffff70:  3fffdad0 00000000 3fff0044 4020a669  
3fffff80:  00000000 00000000 00000001 401003ec  
3fffff90:  3fffdad0 00000000 3fff0044 4010040d  
3fffffa0:  3fffdad0 00000000 3fff0044 4021de50  
3fffffb0:  feefeffe feefeffe 3ffe8664 4010103d  
<<<stack<<<

stack results0x40100c74: umm_get_ptr_context(void*) at C:\Users\rahul.chandrashekar\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.2\cores\esp8266\umm_malloc\umm_malloc.cpp line 2250x40100d75: free(void*) at C:\Users\rahul.chandrashekar\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.2\cores\esp8266\umm_malloc\umm_malloc.cpp line 5930x4021c14d: String::invalidate() at C:\Users\rahul.chandrashekar\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.2\cores\esp8266/WString.h line 2950x402016d9: effector::~effector() at C:\Users\rahul.chandrashekar\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.2\cores\esp8266/WString.h line 790x402052a2: updateConfigPage() at C:\Users\rahul.chandrashekar\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.2\cores\esp8266/WString.h line 790x40208b4c: esp8266webserver::ESP8266WebServerTemplate::_parseRequest(WiFiClient&) at C:\Users\rahul.chandrashekar\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.2\cores\esp8266/WString.h line 790x4021cae0: String::equals(String const&) const at C:\Users\rahul.chandrashekar\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.2\cores\esp8266\WString.cpp line 4920x402232be: std::_Function_handler::_M_invoke(std::_Any_data const&) at c:\users\rahul.chandrashekar\appdata\local\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 2890x401000e9: std::function::operator()() const at c:\users\rahul.chandrashekar\appdata\local\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 6170x4020478d: esp8266webserver::FunctionRequestHandler::handle(esp8266webserver::ESP8266WebServerTemplate&, HTTPMethod, String const&) at C:\Users\rahul.chandrashekar\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.2\libraries\ESP8266WebServer\src/detail/RequestHandlersImpl.h line 420x40209338: esp8266webserver::ESP8266WebServerTemplate::_handleRequest() at c:\users\rahul.chandrashekar\appdata\local\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 4980x40100629: millis() at C:\Users\rahul.chandrashekar\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.2\cores\esp8266\core_esp8266_wiring.cpp line 1930x40209f0a: esp8266webserver::ESP8266WebServerTemplate::handleClient() at C:\Users\rahul.chandrashekar\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.2\libraries\ESP8266WebServer\src/ESP8266WebServer-impl.h line 2740x4021a48c: HardwareSerial::available() at C:\Users\rahul.chandrashekar\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.2\cores\esp8266\HardwareSerial.cpp line 1110x40209ff5: loop() at C:\Users\rahul.chandrashekar\OneDrive - Gentherm\Documents\Arduino\test_0/test_0.ino line 3590x401003ec: ets_post(uint8, ETSSignal, ETSParam) at C:\Users\rahul.chandrashekar\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.2\cores\esp8266\core_esp8266_main.cpp line 1810x4010040d: esp_schedule() at C:\Users\rahul.chandrashekar\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.2\cores\esp8266\core_esp8266_main.cpp line 1280x4021d7dc: loop_wrapper() at C:\Users\rahul.chandrashekar\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.2\cores\esp8266\core_esp8266_main.cpp line 201

Your topic was MOVED to its current forum category which is more appropriate than the original as it has nothing to do with Installation and Troubleshooting of the IDE

1 Like

Weird. It looks like things go wrong when an "effector" object is destructed (effector::~effector). That tries to destruct a String object and the crash happens when the String object tries to free it's allocated memory.

Hi John,

I do not undertand your comment. Pls find the potential place where this error is occuring:

effector eff1;
 EEPROMRead(l1, reinterpret_cast<char*>(&eff1), sizeof(eff1));
    if(!eff1.effectorName.equals("")){
      effector_1_name = eff1.effectorName;
      effectorNameMap->put(eff1.effectorName, "1");
      effectorNameTypeMap->put(eff1.effectorName, eff1.type);
    } 

effectorName is a SimpleMap

Please follow the advice given in the link below when posting code, in particular the section entitled 'Posting code and common code problems'

Use code tags (the </> icon above the compose window) to make it easier to read and copy for examination

A ESP8266 EEPROM is not very large. The code may be going over the EEPROM's size limits.

Good luck.

My guess is that your class "effector" or the SimpleMap class on which it is based contains a String object. When you store a String object (possibly effector::effectorName) in EEPROM you are NOT storing the string data which is in allocated memory. You store the pointer to the allocated memory. When you read that pointer back from EEPROM ( EEPROMRead(l1, reinterpret_cast<char*>(&eff1), sizeof(eff1));) it is no longer valid (the allocated memory it once pointed to is no longer allocated). When the String library tries to free the old data at the invalid pointer: PANIC!

If you want to store your object in EEPROM, make the character data part of the object as a fixed size character array.

Thanks John.
I found the solution. The issue was there were some old values (probably of String) format and it was more of a class cast exception.

Thanks for your comments :slight_smile:

Hi John,

do you have any comments for :slight_smile: .js file within index.h - Using Arduino / Programming Questions - Arduino Forum

Regds
Rahul.

Nope. Not a clue. Can you even run Javacript on a ESP8266?!?

Hi John,

yes - i was able to make this happen. I have posted the code on the channel. It is more of server.send request.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.