Corrected stack start and end in stack_thunk_dump_stack(). by mhightower83 · Pull Request #7085 · esp8266/Arduino (original) (raw)

Can you please explain the logic here, @mhightower83 ? I believe the current code dumps the proper stuff.

My test case:

I've applied something to make the BSSL CertStore crash:

earle@server:~/Arduino/hardware/esp8266com/esp8266/libraries/ESP8266WiFi/src$ git diff
diff --git a/libraries/ESP8266WiFi/src/CertStoreBearSSL.cpp b/libraries/ESP8266WiFi/src/CertStoreBearSSL.cpp
index 905efde2..e7d6312b 100644
--- a/libraries/ESP8266WiFi/src/CertStoreBearSSL.cpp
+++ b/libraries/ESP8266WiFi/src/CertStoreBearSSL.cpp
@@ -212,7 +212,7 @@ const br_x509_trust_anchor *CertStore::findHashedTA(void *ctx, void *hashed_dn,
       br_x509_trust_anchor *ta = (br_x509_trust_anchor*)cs->_x509->getTrustAnchors();
       memcpy(ta->dn.data, ci.sha256, sizeof(ci.sha256));
       ta->dn.len = sizeof(ci.sha256);
-
+ta=(br_x509_trust_anchor*)1;
       return ta;
     }
   }

and run the BSSL_CertStore example. It crashes, as expected, giving a dump:


Connecting to NOBABIES
.
WiFi connected
IP address: 
192.168.1.154
Waiting for NTP time sync: .
Current time: Sun Feb 16 02:09:24 2020
Number of CA certs read: 149
Attempting to fetch https://www.github.com/...
Trying: www.github.com:443...
Exception (9):
epc1=0x4022e0a4 epc2=0x00000000 epc3=0x00000000 excvaddr=0x00000001 depc=0x00000000

>>>stack>>>

ctx: bearssl
sp: 3fff1738 end: 3fff1c58 offset: 0190
3fff18c8:  3fff6e54 3fff6d84 00000000 4022e096  
3fff18d8:  8477bde1 32ce0337 819ac8b5 4e924a1a  
3fff18e8:  859a463b f9a283fe cca38c9e 3db35e0d  
3fff18f8:  8f7804cf deadbeef 00000d00 00000000  
3fff1908:  51cd85fd 59771cc0 c06ad9ab 4396cd84  
3fff1918:  4025e3b7 522daf2c f6f3c118 5123a06c  
3fff1928:  3fff6d9c 000000ba 000006a3 3fff6db0  
3fff1938:  a78cb215 2e5f44dd 3bcd3d87 5b36d405  
....
3fff1c28:  00003a98 00000000 3fff1c64 40226d21  
3fff1c38:  000000db deadbeef deadbeef deadbeef  
3fff1c48:  deadbeef 00000000 3ffeff5c 40204394  

ctx: cont
sp: 3ffffe50 end: 3fffffc0 offset: 0000
3ffffe50:  00003a98 00000000 00000008 40203dba  
3ffffe60:  0000000d 00000005 5845ffaa 00000000  
...
3fffffa0:  3fffdad0 00000000 3ffee780 402061e0  
3fffffb0:  feefeffe feefeffe 3ffe84f0 40100c2d  
<<<stack<<<

Which, with git head, seems to decode just fine:


Exception 9: LoadStoreAlignmentCause: Load or store to an unaligned address
PC: 0x4022e0a4: br_x509_minimal_run at src/x509/x509_minimal.c line 1254
EXCVADDR: 0x00000001

Decoding stack results
0x4022e096: br_x509_minimal_run at src/x509/x509_minimal.c line 1252
0x4022e8b6: xm_append at src/x509/x509_minimal.c line 285
0x40228850: br_ssl_hs_client_run at src/ssl/ssl_hs_client.c line 1871
0x4022683c: jump_handshake at src/ssl/ssl_engine.c line 1081
0x40226d21: br_ssl_engine_recvrec_ack at src/ssl/ssl_engine.c line 1206
0x40203dba: BearSSL::WiFiClientSecure::_run_until(unsigned int, bool) at /home/earle/Arduino/hardware/esp8266com/esp8266/libraries/ESP8266WiFi/src/WiFiClientSecureBearSSL.cpp line 540
0x40226e46: br_ssl_engine_hs_reset at src/ssl/ssl_engine.c line 1305
0x40203ff8: BearSSL::WiFiClientSecure::_wait_for_handshake() at /home/earle/Arduino/hardware/esp8266com/esp8266/libraries/ESP8266WiFi/src/WiFiClientSecureBearSSL.cpp line 564
0x402041db: BearSSL::WiFiClientSecure::_connectSSL(char const*) at /home/earle/Arduino/hardware/esp8266com/esp8266/tools/xtensa-lx106-elf/xtensa-lx106-elf/include/c++/4.8.2/bits/shared_ptr.h line 291
0x402060d3: __esp_yield() at /home/earle/Arduino/hardware/esp8266com/esp8266/cores/esp8266/core_esp8266_main.cpp line 107
0x40206686: __delay(unsigned long) at /home/earle/Arduino/hardware/esp8266com/esp8266/cores/esp8266/core_esp8266_wiring.cpp line 54
0x40202dc8: WiFiClient::connect(IPAddress, unsigned short) at /home/earle/Arduino/hardware/esp8266com/esp8266/libraries/ESP8266WiFi/src/include/ClientContext.h line 133
0x402042f9: BearSSL::WiFiClientSecure::connect(char const*, unsigned short) at /home/earle/Arduino/hardware/esp8266com/esp8266/libraries/ESP8266WiFi/src/WiFiClientSecureBearSSL.cpp line 232
0x40201145: fetchURL(BearSSL::WiFiClientSecure*, char const*, unsigned short, char const*) at /tmp/arduino_modified_sketch_713573/BearSSL_CertStore.ino line 80
0x40203b30: BearSSL::WiFiClientSecure::_clearAuthenticationSettings() at /home/earle/Arduino/hardware/esp8266com/esp8266/libraries/ESP8266WiFi/src/WiFiClientSecureBearSSL.cpp line 104
0x40201356: setup() at /tmp/arduino_modified_sketch_713573/BearSSL_CertStore.ino line 153
0x402061e0: loop_wrapper() at /home/earle/Arduino/hardware/esp8266com/esp8266/cores/esp8266/core_esp8266_main.cpp line 177