calling set() while streaming crashes #48

Open
mimming opened this Issue Jan 28, 2016 · 11 comments

Projects

None yet

6 participants

@mimming
mimming commented Jan 28, 2016

Summary

If you call stream() and then attempt to call set() from from another client, the device panics :(

Steps

Run this code

#include <Firebase.h>


Firebase fbase = Firebase("espbutton.firebaseio.com").auth("REDACTED");
Firebase fbaseStream = Firebase("espbutton.firebaseio.com").auth("SAME_VALUE_ALSO_REDACTED");


void setup() {

  Serial.begin(9600);

  Serial.println("Hello world!");  

  // connect to wifi.
  WiFi.begin("OpenWifiNetworkSSID");
  Serial.print("connecting");
  while (WiFi.status() != WL_CONNECTED) {
    Serial.print(".");
    delay(500);
  }
  Serial.println();
  Serial.print("connected: ");
  Serial.println(WiFi.localIP());

  fbaseStream.stream("/hello");
}

void loop() {
  fbase.set("/", "{\"hello\": \"world\"}");
}

Result

Hello world!
connecting..
connected: 192.168.123.45

Panic /arduino-sketchbook/hardware/esp8266com/esp8266/libraries/ESP8266WiFi/src/WiFiClientSecure.cpp:495 ax_port_malloc

ctx: cont 
sp: 3fff10a0 end: 3fff1520 offset: 01b0

>>>stack>>>
3fff1250:  3fff28f0 00004000 3fff80b5 40203b80  
3fff1260:  36363636 3fff2f58 3fff2f64 40203b0d  
3fff1270:  3fff80b5 00000000 3fff28f0 402294fc  
3fff1280:  3fff80b5 00000000 3fff28f0 4022a8fe  
3fff1290:  00000001 00000001 3fff80a8 40228a9a  
3fff12a0:  e8dc11b0 a2dee883 b0599e2f 000000b9  
3fff12b0:  00000010 3fff80b5 3fff299c 3fff12f0  
3fff12c0:  3fff80b5 3fff28c0 000000e2 00000010  
3fff12d0:  3fff28f0 3fff80b5 00000010 00000010  
3fff12e0:  3fff80b5 00000000 3fff28f0 4022a31e  
3fff12f0:  8ef9144a 72ca9803 93bab03d 66081d08  
3fff1300:  d258f652 00000000 00000034 40229a40  
3fff1310:  00020016 00000014 00000010 00000010  
3fff1320:  0000002f 00000016 3ffe9388 00000004  
3fff1330:  0000002f 3fff28f0 3fff28f0 4022a456  
3fff1340:  0000002f 3fff80a5 3fff28f0 4022a645  
3fff1350:  3fff283c 4021cafa 3fff27c0 00000000  
3fff1360:  00000000 3fff2158 3fff28f0 4022a6d0  
3fff1370:  3fff1d28 3fff1d28 00000001 3fff0394  
3fff1380:  3fff0398 3fff1d28 3fff1c20 40203906  
3fff1390:  b86ac568 3fff1c88 40205524 3fff1c88  
3fff13a0:  00000001 000001bb 3fff1d28 40203bd2  
3fff13b0:  3ffe9190 b86ac568 3fff01f8 402066b0  
3fff13c0:  3fff2430 000001bb 3fff1d28 40202dc5  
3fff13d0:  3ffe9190 b86ac568 3ffe9190 b86ac568  
3fff13e0:  3fff2288 00000000 3ffe8fe2 40205328  
3fff13f0:  3fff0294 00000000 3fff0294 40203be8  
3fff1400:  00000034 00000001 3fff0294 40204398  
3fff1410:  3ffe8ce3 00000012 3fff0294 40204918  
3fff1420:  3ffe8fe2 4010743f 3fff1450 3fff04f4  
3fff1430:  3fff14e8 3fff0294 3fff0294 40203f94  
3fff1440:  3ffe8ce3 00000000 3fff1494 40202660  
3fff1450:  00000000 00000000 00000000 0000008c  
3fff1460:  3ffe8ce3 3fff14dc 3fff0294 40202843  
3fff1470:  00000133 3ffe8ccb 3fff01f8 4020670a  
3fff1480:  3ffe8c89 00000012 3fff14dc 40206762  
3fff1490:  00000000 3fff22c0 0000003f 00000034  
3fff14a0:  3fffdad0 00000000 3fff14dc 3fff04f4  
3fff14b0:  3fffdad0 3fff0294 3fff14d0 40202903  
3fff14c0:  3fff1600 00000000 3fff04ed 4020250d  
3fff14d0:  3ffe8c82 00f0ffff fe9fa8c0 3fff1c88  
3fff14e0:  0000001f 00000012 3fff1608 0000000f  
3fff14f0:  00000001 00000000 00000000 feefeffe  
3fff1500:  feefeffe 00000000 3fff04ed 40205570  
3fff1510:  feefeffe feefeffe 3fff0500 40100114  
<<<stack<<<
��!����!��
@proppy
Collaborator
proppy commented Jan 29, 2016

Might have a similar crash in #42, will try to repo.

@proppy proppy referenced this issue Apr 2, 2016
Open

Firebase serial #71

0 of 4 tasks complete
@proppy
Collaborator
proppy commented Apr 3, 2016

Note this doesn't crash anymore when using https://github.com/esp8266/Arduino master (esp8266/Arduino@5dd6acc).

@BrewCoder

Is it allowed to stream and push at the same time? (even if using two instances of the firebase client) One of the comments in #41 indicates a push is not intended to work during a stream....

I'm looking for a way to stream configuration data/status from one firebase type while pushing / storing sensor data to a different type. I'm able to run each process independently without issues but the system crashes when pushing data with a stream active.

@proppy
Collaborator
proppy commented Apr 5, 2016

@BrewCoder does it also crash with https://github.com/esp8266/Arduino master?

@BrewCoder

@proppy I'm still having the same issue:

Exception (29):
epc1=0x4000e1cc epc2=0x00000000 epc3=0x00000000 excvaddr=0x00000204 depc=0x00000000

ctx: cont
sp: 3fff10c0 end: 3fff1920 offset: 01a0

stack>>>
3fff1260: 00410000 3fff6cec 00000110 4022d5a3
3fff1270: 3fff6db4 3fff701c 00000081 4022e205
3fff1280: 00000210 00000b19 00000b19 4010020c
3fff1290: 3fff738c 3fff7254 00000040 00000000
3fff12a0: 00000014 3fff6cec 00000041 00000041
3fff12b0: 00000000 00000001 00000001 0000007f
3fff12c0: 3fff701c 00000081 3fff701c 402047d4
3fff12d0: 3fff6db4 3fff6cec 3fff6d44 0000007f
3fff12e0: 3fff701c 3fff6cec 3fff6cec 4022e4c1
........

Pseudocode:
Firebase fbaseStream = Firebase("**********.firebaseio.com").auth("Token");
Firebase fbasePush = Firebase("**
********.firebaseio.com").auth("Token");
FirebaseStream stream;

setup(){
stream = fbaseStream.stream("/controls");
}

loop(){
if (stream.error()) {
Serial.println("streaming error");
Serial.println(stream.error().message());
}
if(stream.available()) {
String event;
auto type = stream.read(event);
Serial.print("event: ");
Serial.println(type);
if (type == FirebaseStream::Event::PUT) {
Serial.print("data: ");
Serial.println(event);
}
}

*****every 30 seconds
FirebasePush push = fbasePush.push("/logs", buffer);
if (push.error()) {
Serial.println("Firebase push failed");
Serial.println(push.error().message());
return;
}
}

@proppy proppy added bug core labels Apr 29, 2016
@proppy proppy added this to the lego-workshop milestone May 6, 2016
@proppy proppy removed this from the lego-workshop milestone May 14, 2016
@proppy
Collaborator
proppy commented May 19, 2016

I think this is fixed with arduino-esp8266 master (esp8266/Arduino@43fb139).

I was able to run successfully the following sketch:


FirebaseArduino FirebaseStream;

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

  // connect to wifi.
  WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
  Serial.print("connecting");
  while (WiFi.status() != WL_CONNECTED) {
    Serial.print(".");
    delay(500);
  }
  Serial.println();
  Serial.print("connected: ");
  Serial.println(WiFi.localIP());

  Firebase.begin(FIREBASE_HOST, FIREBASE_AUTH);  
  FirebaseStream.begin(FIREBASE_HOST, FIREBASE_AUTH);
  FirebaseStream.stream("/data");
}

int n = 0;
void loop() {
  Serial.println("loop");
  Firebase.setInt("data", n++);
  if (Firebase.failed()) {
    Serial.println(Firebase.error());
  }
  int data = Firebase.getInt("data");
  if (Firebase.failed()) {
    Serial.println(Firebase.error());
  }
  Serial.print("data: ");
  Serial.println(data);
  Serial.print("heap: ");
  if (FirebaseStream.available()) {
    FirebaseObject event = FirebaseStream.readEvent();
    Serial.print("event: ");
    Serial.println(event.getString("event"));
    Serial.print("path: ");
    Serial.println(event.getString("path"));
    Serial.print("data: ");
    Serial.println(event.getInt("data"));
  }
  Serial.println(ESP.getFreeHeap());
  delay(1000);
}
@proppy
Collaborator
proppy commented May 19, 2016

@BrewCoder can you try again?

@mininao
mininao commented Jun 3, 2016

I think I have the same issue, with esp8266/arduino pulled straight from master.
Here is the simplest repro I could make : https://gist.github.com/mininao/a3f29eebb39c18c8104ae28e2a74b747
It crashes a few seconds after turning in on, leaving the output that's in the gist

@tabvn
tabvn commented Jul 1, 2016 edited

I confirm that problem still exit , we could not push during stream #185

@proppy proppy added this to the 0.1 milestone Oct 5, 2016
@ed7coyne
Collaborator

I dug into this a bit last week. The problem is having two SSL connections at the same time. I believe the issue is due to a lack of ram.

Here is a simplified .ino based on the esp's streaming example, that will also crash: https://gist.github.com/ed7coyne/678398bb0d9fa1f826d581650606267a

Here is an issue on the esp core that I beleive to be the root cause: esp8266/Arduino#2201

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment