Skip to content

Commit ebae47c

Browse files
Expand BSSL stack (#6819)
Fixes #6811 which found an issue where connecting to scripts.google.com would *occasionally* cause a crash. On inspection, it was found that up to 5828 bytes of stack were used once in a while, so expand the stack to 5900 bytes to cover this case plus a little extra.
1 parent 007e495 commit ebae47c

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

cores/esp8266/StackThunk.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ uint32_t *stack_thunk_top = NULL;
3636
uint32_t *stack_thunk_save = NULL; /* Saved A1 while in BearSSL */
3737
uint32_t stack_thunk_refcnt = 0;
3838

39-
#define _stackSize (5748/4)
39+
/* Largest stack usage seen in the wild at scripts.google.com at 5828 */
40+
#define _stackSize (5900/4)
4041
#define _stackPaint 0xdeadbeef
4142

4243
/* Add a reference, and allocate the stack if necessary */

libraries/ESP8266WiFi/examples/BearSSL_Validation/BearSSL_Validation.ino

+3-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
#include <ESP8266WiFi.h>
88
#include <WiFiClientSecure.h>
9+
#include <StackThunk.h>
910
#include <time.h>
1011

1112
#ifndef STASSID
@@ -81,7 +82,8 @@ void fetchURL(BearSSL::WiFiClientSecure *client, const char *host, const uint16_
8182
}
8283
client->stop();
8384
uint32_t freeStackEnd = ESP.getFreeContStack();
84-
Serial.printf("\nCONT stack used: %d\n-------\n\n", freeStackStart - freeStackEnd);
85+
Serial.printf("\nCONT stack used: %d\n", freeStackStart - freeStackEnd);
86+
Serial.printf("BSSL stack used: %d\n-------\n\n", stack_thunk_get_max_usage());
8587
}
8688

8789
void fetchNoConfig() {

0 commit comments

Comments
 (0)