Quantcast
Channel: Arduino Forum - Latest topics
Viewing all articles
Browse latest Browse all 15514

Why does filling up a large char array cause a crash? (ESP8266)

$
0
0

Here's the code in question:

void setup() {  
  Serial.begin(115200);
  Serial.println();
  Serial.println();

  char test[5000];
  int x;
  for(x = 0; x < sizeof(test)-1; x++){
    test[x] = 'x';
    Serial.println(x);
    yield();
  }
  Serial.println("Going to print string: ");
  test[x]='\0';
  Serial.println(test);

}

void loop() {
  // put your main code here, to run repeatedly:

}

The crash I get on my NodeMCU ESP8266, on the 828th iteration of the loop every time:

...
827
828

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

wdt reset
load 0x4010f000, len 3424, room 16 
tail 0
chksum 0x2e
load 0x3fff20b8, len 40, room 8 
tail 0

if I decrease the length of the array to 4000, I get a different crash, on the FIRST iteration:

0

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

Panic core_esp8266_main.cpp:191 __yield

>>>stack>>>

ctx: sys
sp: 3fffefd0 end: 3fffffb0 offset: 0010
3fffefe0:  00000f9f 00000001 3ffee4f8 40201905  
3fffeff0:  0000009f 00000000 3ffee4f8 4020107b  
3ffff000:  feefef78 feefeffe feefeffe feefeffe  
3ffff010:  feefeffe feefeffe feefeffe feefeffe  
3ffff020:  feefeffe feefeffe feefeffe feefeffe  
3ffff030:  feefeffe feefeffe feefeffe feefeffe  
...

If I decrease the length of the array further, to 3000, nothing happens and the program runs normally as it should.

What is going on here?

8 posts - 3 participants

Read full topic


Viewing all articles
Browse latest Browse all 15514

Trending Articles