-
Notifications
You must be signed in to change notification settings - Fork 13.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Random crashes with multiple http requests #2504
Comments
You said
Which page exactly in your github code is it that you're refreshing when you experience this crash? If it's https://github.com/burner-/ESPRelayThermostat/blob/master/data/index.html that you're talking about, my suggestion is that you inline all js and css directly into this html doc, gzip the html doc and serve that gzipped doc. At the moment, 1 request for this page will actually result in 6 requests because of the css and js resources being included and the crash you're seeing could be the result of these multiple requests overwhelming the device. 1 request with a single compressed response would be a better idea. |
That is just workaround not fix. Yes with less loads it is less likely that it crash. But crashes and random stuck come with all pages. So I think it is preferred to first fix problem. Then optimize that all files are at one bundle. Another way it is like first hide that random problem to even more rare and then try to fix it. |
Sure you've got a valid point there and I'm certain that you've identified an actual problem here. I've seen these symptoms myself on occasion too and I chose to implement the workaround rather than going after the actual problem and the workaround does seem to have settled things down to a reasonably stable level for my use cases. That said, attempting to locate the underlying cause of this problem is worth pursuing. |
Looks that in ESP8266WebServer/src/Parsing.cpp there is malloc at readBytesWithTimeout. It returns to line 180. at row 207 there is free. But if content lenght is 0 then it does not free that allocation at all? I try move that free out from that if. It did not help (at least not resolve all crashes) but is that also one bug? |
I agree this code path does look odd and it seems to be an improvement if the free on this line
The readBytesWithTimeout call / plainBuf allocation is all in the context of |
Do you know reason why with nodemcu 1.0 Debug menu item is missing under tools? Is it bug or feature :) |
I now add debug parameters to boards.txt for nodemcu. Looks that some of crashes are "just random" and probably there is several different bugs at core. Anyhow probably is best to start from somewhere. I start feeling that we are at so deep waters that we need @igrr to save us :) Edit: I noted that row numbers does not match -> this has nothing to do with clock frequency Request: /favicon.ico Panic C:\Arduino\arduino-1.6.11\hardware\esp8266com\esp8266\libraries\ESP8266WiFi\src\include/DataSource.h:72 const uint8_t* BufferedStreamDataSource::get_buffer(size_t) [with TStream = Stream; uint8_t = unsigned char; size_t = unsigned int] ctx: cont
ets Jan 8 2013,rst cause:4, boot mode:(3,6) wdt reset ~ldDecoding 39 results |
The only time I can say I've experienced seemingly random crashes and completely unexplained behaviour is when the power supply has been unstable. If it's a NodeMCU dev kit board with USB power you're working with, I'm afraid I don't have any experience with these types of boards. |
I am not so sure are they completely random. after I comment out that panic() under yield then it stats looking that there is just lot of different kind exceptions that network stack try read or write wrong memory areas (LoadStoreAlignmentCause, StoreProhibitedCause) |
@burner- I experienced this myself. I believe it's a combination of sync WifiServer and lwip 1.4, and it happens when the server receives a request when a previous request isn't done yet (browser quick refresh, concurrent requests of webpage elements, etc).
|
Will second @devyte 's comment on " when the server receives a request when a previous request isn't done yet (browser quick refresh, concurrent requests of webpage elements, etc).". When I stress test my esp8266 project that serves a page with websockets, spamming requests causes my esp to gradually lose ram until it resets. |
@eighthree what does your stress test look like? |
Some context...
The stress test...
Typical errors found when the esp crashesdev 1153
ets Jan 8 2013,rst cause:4, boot mode:(3,6)
wdt reseta
load 0x4010f000, len 1384, room 16
tail 8
chksum 0x2d
csum 0x2d
v00000000
~ld ets Jan 8 2013,rst cause:2, boot mode:(1,7)
ets Jan 8 2013,rst cause:4, boot mode:(1,7)
wdt reset
Exception 29: StoreProhibited: A store referenced a page mapped with an attribute that does not permit stores
Decoding 23 results
0x402378ef: pp_attach at ?? line ?
0x40226012: ieee80211_alloc_proberesp at ?? line ?
0x40225f30: ieee80211_alloc_proberesp at ?? line ?
0x401011de: pp_post at ?? line ?
0x40227824: scan_profile_check at ?? line ?
0x402260df: ieee80211_send_proberesp at ?? line ?
0x401007ec: calloc at C:\Users\eight\Documents\Arduino\hardware\esp8266com\esp8266\cores\esp8266\umm_malloc/umm_malloc.c line 1693
0x40222c30: hostap_input at ?? line ?
0x40222b03: hostap_input at ?? line ?
0x40228a43: sta_input at ?? line ?
0x40228aae: sta_input at ?? line ?
0x4022a771: cnx_node_search at ?? line ?
0x4022233f: hostap_input at ?? line ?
0x40236b70: ppRecycleRxPkt at ?? line ?
0x40104cfe: wdt_feed at ?? line ?
0x40236ea6: pp_tx_idle_timeout at ?? line ?
0x4023679b: ppPeocessRxPktHdr at ?? line ?
0x4021424f: loop_task at C:\Users\eight\Documents\Arduino\hardware\esp8266com\esp8266\cores\esp8266/core_esp8266_main.cpp line 57
Fatal exception 29(StoreProhibitedCause):
epc1=0x4000e1c3, epc2=0x00000000, epc3=0x00000000, excvaddr=0x00000018, depc=0x00000000
Exception (29):
epc1=0x4000e1c3 epc2=0x00000000 epc3=0x00000000 excvaddr=0x00000018 depc=0x00000000
ctx: sys
sp: 3ffffc50 end: 3fffffb0 offset: 01a0
>>>stack>>>
3ffffdf0: 00006d30 4021df94 00000000 00000030
3ffffe00: 40226012 40225f30 3fff4e94 00000008
3ffffe10: 40237900 00000001 40227824 3ffffed0
3ffffe20: 00000018 3fff13f8 3fff1374 00000000
3ffffe30: 402260df 3ff20a00 3fff4e94 3ffed826
3ffffe40: 3ffed80c 3ffffed0 3ffffed0 3fff5144
3ffffe50: 00000038 7269616c 3fff2f54 3ffed80c
3ffffe60: 00000000 3fff9b1c 00000038 401007ec
3ffffe70: 3ffed816 3fff5344 40222c30 3ff20a00
3ffffe80: 3fff4e94 3fff9b24 00000015 40222b03
3ffffe90: 3fff21b0 3fff4adc 00000000 40228a43
3ffffea0: 00000000 028afb88 40228aae 3fff4adc
3ffffeb0: 3fff4ac4 ffffffc7 00000000 ffffffff
3ffffec0: 40000f58 00000000 00000020 00000000
3ffffed0: 00000000 10310b0b 00640100 00000051
3ffffee0: 3ffede74 00000095 3ffede95 3ffede68
3ffffef0: 3ffede9b 3ffede74 00000003 3ffedea6
3fffff00: 4022a771 ffffffa3 00000000 3ffedec9
3fffff10: 4022233f 3ffed80c 3fff0948 3fff4e94
3fffff20: 00000000 3ffed816 3ffed82c 00000000
3fffff30: 40236b70 00000000 00000000 3ffed816
3fffff40: 40104cfe 00000064 3fff0948 3fff5344
3fffff50: 3ffed800 00000000 00000003 40236ea6
3fffff60: 3fff0948 3ffed800 3fffdcc0 3ffed038
3fffff70: 3ffed81c 3fff5144 00000040 3ffed038
3fffff80: 00000040 3fff0948 00000000 3fff3040
3fffff90: 4023679b 3fffdab0 00000000 4021424f
3fffffa0: 3ffed038 40000f49 3fffdab0 40000f49
<<<stack<<<
ets Jan 8 2013,rst cause:2, boot mode:(1,7)
ets Jan 8 2013,rst cause:4, boot mode:(1,7)
wdt reset
Exception 29: StoreProhibited: A store referenced a page mapped with an attribute that does not permit stores
Decoding 23 results
0x4021df94: igmp_timer at core/timers.c line 217
0x40226012: ieee80211_alloc_proberesp at ?? line ?
0x40225f30: ieee80211_alloc_proberesp at ?? line ?
0x40237900: pp_attach at ?? line ?
0x40227824: scan_profile_check at ?? line ?
0x402260df: ieee80211_send_proberesp at ?? line ?
0x401007ec: calloc at C:\Users\eight\Documents\Arduino\hardware\esp8266com\esp8266\cores\esp8266\umm_malloc/umm_malloc.c line 1693
0x40222c30: hostap_input at ?? line ?
0x40222b03: hostap_input at ?? line ?
0x40228a43: sta_input at ?? line ?
0x40228aae: sta_input at ?? line ?
0x4022a771: cnx_node_search at ?? line ?
0x4022233f: hostap_input at ?? line ?
0x40236b70: ppRecycleRxPkt at ?? line ?
0x40104cfe: wdt_feed at ?? line ?
0x40236ea6: pp_tx_idle_timeout at ?? line ?
0x4023679b: ppPeocessRxPktHdr at ?? line ?
0x4021424f: loop_task at C:\Users\eight\Documents\Arduino\hardware\esp8266com\esp8266\cores\esp8266/core_esp8266_main.cpp line 57 |
@eighthree with latest master, can you enable all debug logs and show the serial console before the crash ? |
I had a similar problem. I found the bug and will submit a fix today. |
… buf, size_t size) (esp8266#2504)
@d-a-v I had all the debug options enabled but serial does not show anything other than what i've posted. Tested the fix @mongozmaki mentioned but still having the same issue. |
… buf, size_t size) (esp8266#2504) (esp8266#4530) * Fix random crashing of ClientContext::write(Stream) and write_P(PGM_P buf, size_t size) (esp8266#2504) * - Allow partial buffer release * - Refined comments (cherry picked from commit 3267443)
@burner- @eighthree a lot has changed since this was last discussed. Is the issue still valid with latest git and lwip2? |
No response in a long time. Closing. |
Basic Infos
After long consideration I decide to make issue of that. I am still not sure is that problem at my code or at core but I am out of options and because all happened at core I start believe that this problem can be at core. All suggestions are welcome to narrow down this problem.
Problem is reproducible with this project https://github.com/burner-/ESPRelayThermostat and if you dont want wait long time that problem come just refresh web page multiple times.
Hardware
Hardware: nodemcu 1.0
Core Version: 10.9.2016 version of git
Description
Problem is that all other things work fine but when I load that web page it randomly crash at different locations in core librarys. Some times it also just stuck without wdt reset. Every time crash is at core. Most of crashes are are at area where http library serve files from filesystem. Usual when it reset or stuck without callstack it serving dynamic data, not file from filesystem. Only connected thing is ds18b20 sensor and power come from usb 3 port directly to nodemcu so issue should not be at regulator/power issue.
Some times it looks like there is some kind race condition between udp and http client or even at http client but this is just guessing.
Settings in IDE
Module: ?Generic ESP8266 Module?
Flash Size: ?4MB/1MB?
CPU Frequency: ?80Mhz?
Flash Mode: ?qio?
Flash Frequency: ?40Mhz?
Upload Using: ?OTA / SERIAL?
Reset Method: ?ck / nodemcu?
Sketch
https://github.com/burner-/ESPRelayThermostat
At attachment there is list of some crashes.
crashlist.txt
The text was updated successfully, but these errors were encountered: