0

My project involves a bunch of peripherals, but most importantly for this project, a request to an NTP time server is done using the standard NTPClient library. Suddenly, after modifying some seemingly unrelated parts of the code involving SdFat, the ESP8266 started crashing each time in the same place, somewhere deep within the networking firmware.

I have now had this problem with multiple variations, but every time, the crashing function was something that the Exception Decoder calls check_poison_neighbors(unsigned short). It appears to be nested in some memory allocating functions (guessing by the malloc names).

Below is the entire output of ESP Exception Decoder from one of the crashes.

Exception 3: LoadStoreError: Processor internal physical address or data error during load or store
PC: 0x40100fb5: check_poison_neighbors(unsigned short) at C:\Users\USERNAME\Documents\ArduinoData\packages\esp8266\hardware\esp8266\2.7.1\cores\esp8266\umm_malloc/umm_local.c line 52
EXCVADDR: 0x40010059

Decoding stack results
0x4010109d: umm_malloc_core(size_t) at C:\Users\USERNAME\Documents\ArduinoData\packages\esp8266\hardware\esp8266\2.7.1\cores\esp8266\umm_malloc\umm_malloc.cpp line 422
0x4022cae4: mem_malloc at core/mem.c line 210
0x4010131c: umm_malloc(size_t) at C:\Users\USERNAME\Documents\ArduinoData\packages\esp8266\hardware\esp8266\2.7.1\cores\esp8266\umm_malloc\umm_malloc.cpp line 511
0x4010017c: ets_post(uint8, ETSSignal, ETSParam) at C:\Users\USERNAME\Documents\ArduinoData\packages\esp8266\hardware\esp8266\2.7.1\cores\esp8266\core_esp8266_main.cpp line 177
0x4010134b: umm_poison_malloc(size_t) at C:\Users\USERNAME\Documents\ArduinoData\packages\esp8266\hardware\esp8266\2.7.1\cores\esp8266\umm_malloc/umm_poison.c line 155
0x4010072e: malloc(size_t) at C:\Users\USERNAME\Documents\ArduinoData\packages\esp8266\hardware\esp8266\2.7.1\cores\esp8266\heap.cpp line 228
0x4022cae4: mem_malloc at core/mem.c line 210
0x40226984: pbuf_alloc_LWIP2 at core/pbuf.c line 284
0x4022443c: dns_send at core/dns.c line 777
0x402245f7: dns_check_entry at core/dns.c line 1096
0x40224b11: dns_gethostbyname_addrtype at core/dns.c line 1502
0x40208a0c: wifi_dns_found_callback(char const*, ip4_addr const*, void*) at C:\Users\USERNAME\Documents\ArduinoData\packages\esp8266\hardware\esp8266\2.7.1\libraries\ESP8266WiFi\src\ESP8266WiFiGeneric.cpp line 707
0x40224b68: dns_gethostbyname at core/dns.c line 1530
0x40208b80: ESP8266WiFiGenericClass::hostByName(char const*, IPAddress&, unsigned int) at C:\Users\USERNAME\Documents\ArduinoData\packages\esp8266\hardware\esp8266\2.7.1\libraries\ESP8266WiFi\src\ESP8266WiFiGeneric.cpp line 623
0x4020e554: operator new(unsigned int) at C:\Users\USERNAME\Documents\ArduinoData\packages\esp8266\hardware\esp8266\2.7.1\cores\esp8266\abi.cpp line 39
0x40209b3f: WiFiUDP::begin(unsigned short) at C:\Users\USERNAME\Documents\ArduinoData\packages\esp8266\hardware\esp8266\2.7.1\libraries\ESP8266WiFi\src\WiFiUdp.cpp line 83
0x4010072e: malloc(size_t) at C:\Users\USERNAME\Documents\ArduinoData\packages\esp8266\hardware\esp8266\2.7.1\cores\esp8266\heap.cpp line 228
0x4022cae4: mem_malloc at core/mem.c line 210
0x4020e554: operator new(unsigned int) at C:\Users\USERNAME\Documents\ArduinoData\packages\esp8266\hardware\esp8266\2.7.1\cores\esp8266\abi.cpp line 39
0x40209b3f: WiFiUDP::begin(unsigned short) at C:\Users\USERNAME\Documents\ArduinoData\packages\esp8266\hardware\esp8266\2.7.1\libraries\ESP8266WiFi\src\WiFiUdp.cpp line 83
0x40208c00: ESP8266WiFiGenericClass::hostByName(char const*, IPAddress&) at C:\Users\USERNAME\Documents\ArduinoData\packages\esp8266\hardware\esp8266\2.7.1\libraries\ESP8266WiFi\src\ESP8266WiFiGeneric.cpp line 605
0x402095bc: WiFiUDP::beginPacket(char const*, unsigned short) at C:\Users\USERNAME\Documents\ArduinoData\packages\esp8266\hardware\esp8266\2.7.1\libraries\ESP8266WiFi\src\WiFiUdp.cpp line 140
0x40209b3f: WiFiUDP::begin(unsigned short) at C:\Users\USERNAME\Documents\ArduinoData\packages\esp8266\hardware\esp8266\2.7.1\libraries\ESP8266WiFi\src\WiFiUdp.cpp line 83
0x40209db1: NTPClient::sendNTPPacket() at C:\Users\USERNAME\Documents\_H\Arduino\libraries\NTPClient\NTPClient.cpp line 174
0x40209df1: NTPClient::forceUpdate() at C:\Users\USERNAME\Documents\_H\Arduino\libraries\NTPClient\NTPClient.cpp line 76
0x40209e93: NTPClient::update() at C:\Users\USERNAME\Documents\_H\Arduino\libraries\NTPClient\NTPClient.cpp line 99
0x40205317: setup() at PROJECT_MAIN_FILE.ino line 173
0x4020e7e4: loop_wrapper() at C:\Users\USERNAME\Documents\ArduinoData\packages\esp8266\hardware\esp8266\2.7.1\cores\esp8266\core_esp8266_main.cpp line 194

Lines 170-173 in my main project file read:

// start ntp client
timeClient.begin();
timeClient.update();
yield();

The code before that ensures that a WLAN (WiFi) connection has been established, which I also confirmed from the ESP internal debug output to the serial port.

This is one of the lifecycle serial logs:

SDK:2.2.2-dev(38a443e)/Core:2.7.1=20701000/lwIP:STABLE-2_1_2_RELEASE/glue:1.2-30-g92add50/BearSSL:5c771be
# SD ok.
scandone
state: 0 -> 2 (b0)
state: 2 -> 3 (0)
state: 3 -> 5 (10)
add 0
aid 2
cnt 

connected with ACCESS_POINT_NAME, channel 11
dhcp client start...
wifi evt: 0
ip:192.168.178.76,mask:255.255.255.0,gw:192.168.178.1
wifi evt: 3
# Display ok.
# Waiting on WLAN
# WLAN connected.
[hostByName] request IP for: europe.pool.ntp.org
[hostByName] Host: europe.pool.ntp.org IP: 212.92.16.193
:urn 48
:urd 48, 48, 0
# Checking status...

 ets Jan  8 2013,rst cause:4, boot mode:(3,6)

wdt reset
load 0x4010f000, len 3456, room 16 
tail 0
chksum 0x84
csum 0x84
va5432625
~ld

The lines starting with "#" are my own logging output which confirms external hardware and WLAN connectivity. Note the [hostByName] lines, which are triggered by the NTP client's DNS lookup. Somewhat randomly, on some resets they will not show up and I will get the above exception and stack trace, and other times, like shown in this serial log, they do show up and the ESP8266 resets without causing an explicit exception and stack trace log. Weird.

I have checked multiple solutions and reflashed the firmware etc. Flash is 415660 Bytes (39%) and global variables 32848 Bytes (40%). Any help would be appreciated.

  • cause 4 is watchdog reset – Juraj Jul 8 at 18:51
  • If you're corrupting memory, the crash will most likely not happen where you cause the problem, it will happen in other code that's working with the damaged area of memory. If you can cut your program down to at the smallest program that still demonstrates the problem, someone may be able to point out the issue to you. You might even find it yourself. – romkey Jul 8 at 20:09
  • Thanks. I have found a wrong allocation inside some other code, fixing that leads to new poison errors I may be able to track futher. – kleines filmröllchen Jul 8 at 21:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.