Skip to content
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

Intermittent exception thrown when validating client cert #86

Closed
8none1 opened this issue Aug 3, 2020 · 4 comments
Closed

Intermittent exception thrown when validating client cert #86

8none1 opened this issue Aug 3, 2020 · 4 comments

Comments

@8none1
Copy link

8none1 commented Aug 3, 2020

On an ESP8266 (Node MCU v1 clone) calling
client.validateConnection();
usually results in an exception being thrown.

Most of the time it is this

--------------- CUT HERE FOR EXCEPTION DECODER ---------------

Exception (9):
epc1=0x4020c59c epc2=0x00000000 epc3=0x00000000 excvaddr=0x32e0c112 depc=0x00000000

>>>stack>>>

ctx: cont
sp: 3ffffc60 end: 3fffffc0 offset: 0190
3ffffdf0:  3fff19dc 3fff2564 3ffefd84 4020ba97  
3ffffe00:  000000d0 3ffeeb70 00000001 402079cc  
3ffffe10:  00000000 00000000 00000000 402081ea  
3ffffe20:  00000000 3ffefd84 3fff19a4 40203378  
3ffffe30:  3ffeea44 00000d50 00000000 00000000  
3ffffe40:  000001bb 3ffefd84 3fff19dc 00000000  
3ffffe50:  000001bb 3ffefd84 3fff19dc 4020bc6d  
3ffffe60:  4020c9f0 1a16d622 4020c9f0 1a16d622  
3ffffe70:  3ffefd84 3ffee96c 3ffee960 40204b79  
3ffffe80:  3ffee960 ffffffff 3ffffed4 40206ac5  
3ffffe90:  3ffe8905 00000006 3ffee998 00000000  
3ffffea0:  00000000 00000000 3ffee960 4020580f  
3ffffeb0:  00000658 000000cb 000000cb 4010071f  
3ffffec0:  00000000 80000034 6e6e6f00 3ffeeb14  
3ffffed0:  3ffe890d 00000001 00000000 401009a7  
3ffffee0:  72657300 6567412d 8000746e 40206fe0  
3ffffef0:  3fffff20 00000000 3fffff2c 3ffeeb14  
3fffff00:  3ffee960 00000001 3ffee8d0 4020597a  
3fffff10:  3ffee960 00000001 3ffee8d0 40203fc2  
3fffff20:  3ffef700 0010001f 80feea98 65636300  
3fffff30:  3f007470 8000000a 3fff206c 0034003f  
3fffff40:  0027e7b2 80ffff60 3ffeea98 40206ae4  
3fffff50:  3ffeea10 3ffeea04 3ffeea98 4020125f  
3fffff60:  3ffefc00 000f000f 80efeffe feefeffe  
3fffff70:  feefeffe feefeffe feefeffe feefeffe  
3fffff80:  feefeffe feefeffe 72657300 feefef00  
3fffff90:  80efeffe feefeffe feefeffe feefeffe  
3fffffa0:  3fffdad0 00000000 3ffeead4 40207adc  
3fffffb0:  feefeffe feefeffe 3ffe8534 40100c61  
<<<stack<<<

--------------- CUT HERE FOR EXCEPTION DECODER ---------------

but some times it is this:

--------------- CUT HERE FOR EXCEPTION DECODER ---------------

Exception (28):
epc1=0x4020c598 epc2=0x00000000 epc3=0x00000000 excvaddr=0x014101cc depc=0x00000000

>>>stack>>>

ctx: cont
sp: 3ffffc60 end: 3fffffc0 offset: 0190
3ffffdf0:  3fff19dc 3fff2564 3ffefd84 4020ba97  
3ffffe00:  00000097 3ffeeb70 00000001 402079cc  
3ffffe10:  00000000 00000000 00000000 402081ea  
3ffffe20:  00000000 3ffefd84 3fff19a4 40203378  
3ffffe30:  3ffeea44 00000d50 00000000 00000000  
3ffffe40:  000001bb 3ffefd84 3fff19dc 00000000  
3ffffe50:  000001bb 3ffefd84 3fff19dc 4020bc6d  
3ffffe60:  4020c9f0 1a16d622 4020c9f0 1a16d622  
3ffffe70:  3ffefd84 3ffee96c 3ffee960 40204b79  
3ffffe80:  3ffee960 ffffffff 3ffffed4 40206ac5  
3ffffe90:  3ffe8905 00000006 3ffee998 00000000  
3ffffea0:  00000000 00000000 3ffee960 4020580f  
3ffffeb0:  00000658 000000cb 000000cb 4010071f  
3ffffec0:  00000000 80000034 6e6e6f00 3ffeeb14  
3ffffed0:  3ffe890d 00000001 00000000 401009a7  
3ffffee0:  72657300 6567412d 8000746e 40206fe0  
3ffffef0:  3fffff20 00000000 3fffff2c 3ffeeb14  
3fffff00:  3ffee960 00000001 3ffee8d0 4020597a  
3fffff10:  3ffee960 00000001 3ffee8d0 40203fc2  
3fffff20:  3ffef700 0010001f 80feea98 65636300  
3fffff30:  3f007470 80000000 3fff206c 0034003f  
3fffff40:  00000017 80ffff60 3ffeea98 40206ae4  
3fffff50:  3ffeea10 3ffeea04 3ffeea98 4020125f  
3fffff60:  3ffefc00 000f000f 80efeffe feefeffe  
3fffff70:  feefeffe feefeffe feefeffe feefeffe  
3fffff80:  feefeffe feefeffe 72657300 feefef00  
3fffff90:  80efeffe feefeffe feefeffe feefeffe  
3fffffa0:  3fffdad0 00000000 3ffeead4 40207adc  
3fffffb0:  feefeffe feefeffe 3ffe8534 40100c61  
<<<stack<<<

--------------- CUT HERE FOR EXCEPTION DECODER ---------------

This reboots the board and then it gets in to an exception reboot loop. Some times it will get itself out of this loop and then once the main loop starts running things are generally pretty stable.

If I comment out the validateConnection() function call things seem to work fine.

Thanks for all your work on this excellent library. Let me know if I can help debug some more.

@8none1
Copy link
Author

8none1 commented Aug 3, 2020

Update: Sometimes I'm seeing the exception in other places now, e.g when trying to write data. I seem to be able to work around this by either reflashing the sketch or resetting the board with the reset button.

@vlastahajek
Copy link
Collaborator

@8none1, please, decode the exception and stack dump using EspExceptionDecoder.

What version of this library do you use?
What is the version of the ESP8266 Arduino SDK?

@8none1
Copy link
Author

8none1 commented Aug 4, 2020

Here's a couple of decoded exceptions. They both seem to crash at the same point in BearSSLHelpers.cpp

Exception 9: LoadStoreAlignmentCause: Load or store to an unaligned address
PC: 0x4020c454: BearSSL::PrivateKey::isRSA() const at /Users/wcooke/Library/Arduino15/packages/esp8266/hardware/esp8266/2.7.3/libraries/ESP8266WiFi/src/BearSSLHelpers.cpp line 734
EXCVADDR: 0xffffffff

Decoding stack results
0x4020b953: BearSSL::WiFiClientSecure::_connectSSL(char const*) at /Users/wcooke/Library/Arduino15/packages/esp8266/hardware/esp8266/2.7.3/libraries/ESP8266WiFi/src/WiFiClientSecureBearSSL.cpp line 1093
0x40207888: __esp_yield() at /Users/wcooke/Library/Arduino15/packages/esp8266/hardware/esp8266/2.7.3/cores/esp8266/core_esp8266_main.cpp line 119
0x402080a6: __delay(unsigned long) at /Users/wcooke/Library/Arduino15/packages/esp8266/hardware/esp8266/2.7.3/cores/esp8266/core_esp8266_wiring.cpp line 54
0x40203380: WiFiClient::connect(IPAddress, unsigned short) at /Users/wcooke/Library/Arduino15/packages/esp8266/hardware/esp8266/2.7.3/libraries/ESP8266WiFi/src/include/ClientContext.h line 144
0x4020bb29: BearSSL::WiFiClientSecure::connect(char const*, unsigned short) at /Users/wcooke/Library/Arduino15/packages/esp8266/hardware/esp8266/2.7.3/libraries/ESP8266WiFi/src/WiFiClientSecureBearSSL.cpp line 229
0x40204a85: HTTPClient::connect() at /Users/wcooke/Library/Arduino15/packages/esp8266/hardware/esp8266/2.7.3/libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.cpp line 1235
0x40206b98: String::copy(char const*, unsigned int) at /Users/wcooke/Library/Arduino15/packages/esp8266/hardware/esp8266/2.7.3/cores/esp8266/WString.cpp line 214
0x4020571b: HTTPClient::sendRequest(char const*, unsigned char const*, unsigned int) at /Users/wcooke/Library/Arduino15/packages/esp8266/hardware/esp8266/2.7.3/libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.cpp line 681
0x4020491e: HTTPClient::collectHeaders(char const**, unsigned int) at /Users/wcooke/Library/Arduino15/packages/esp8266/hardware/esp8266/2.7.3/libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.cpp line 1157
0x402069b5: String::invalidate() at /Users/wcooke/Library/Arduino15/packages/esp8266/hardware/esp8266/2.7.3/cores/esp8266/WString.cpp line 140
0x40203e8a: InfluxDBClient::preRequest() at /Users/wcooke/Documents/Arduino/libraries/ESP8266_Influxdb/src/InfluxDbClient.cpp line 533
0x4020588c: HTTPClient::POST(unsigned char const*, unsigned int) at /Users/wcooke/Library/Arduino15/packages/esp8266/hardware/esp8266/2.7.3/libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.cpp line 612
0x40203fee: InfluxDBClient::postData(char const*) at /Users/wcooke/Documents/Arduino/libraries/ESP8266_Influxdb/src/InfluxDbClient.cpp line 553
0x4010071f: umm_free_core(void*) at /Users/wcooke/Library/Arduino15/packages/esp8266/hardware/esp8266/2.7.3/cores/esp8266/umm_malloc/umm_malloc.cpp line 351
0x4020407d: InfluxDBClient::flushBuffer() at /Users/wcooke/Documents/Arduino/libraries/ESP8266_Influxdb/src/InfluxDbClient.cpp line 413
0x40206b4f: String::reserve(unsigned int) at /Users/wcooke/Library/Arduino15/packages/esp8266/hardware/esp8266/2.7.3/cores/esp8266/WString.cpp line 146
0x402069b5: String::invalidate() at /Users/wcooke/Library/Arduino15/packages/esp8266/hardware/esp8266/2.7.3/cores/esp8266/WString.cpp line 140
0x4020418f: InfluxDBClient::checkBuffer() at /Users/wcooke/Documents/Arduino/libraries/ESP8266_Influxdb/src/InfluxDbClient.cpp line 399
0x402041f5: InfluxDBClient::writeRecord(String&) at /Users/wcooke/Documents/Arduino/libraries/ESP8266_Influxdb/src/InfluxDbClient.cpp line 385
0x40204241: InfluxDBClient::writePoint(Point&) at /Users/wcooke/Documents/Arduino/libraries/ESP8266_Influxdb/src/InfluxDbClient.cpp line 362
0x40206574: Print::println(char const*) at /Users/wcooke/Library/Arduino15/packages/esp8266/hardware/esp8266/2.7.3/cores/esp8266/Print.cpp line 198
0x40201598: loop() at /Users/wcooke/Documents/Arduino/anais/anais.ino line 126
0x402079a0: loop_wrapper() at /Users/wcooke/Library/Arduino15/packages/esp8266/hardware/esp8266/2.7.3/cores/esp8266/core_esp8266_main.cpp line 197
Exception 28: LoadProhibited: A load referenced a page mapped with an attribute that does not permit loads
PC: 0x4020c5a8: BearSSL::PrivateKey::isRSA() const at /Users/wcooke/Library/Arduino15/packages/esp8266/hardware/esp8266/2.7.3/libraries/ESP8266WiFi/src/BearSSLHelpers.cpp line 734
EXCVADDR: 0x00043a80

Decoding stack results
0x4020baa7: BearSSL::WiFiClientSecure::_connectSSL(char const*) at /Users/wcooke/Library/Arduino15/packages/esp8266/hardware/esp8266/2.7.3/libraries/ESP8266WiFi/src/WiFiClientSecureBearSSL.cpp line 1093
0x402079dc: __esp_yield() at /Users/wcooke/Library/Arduino15/packages/esp8266/hardware/esp8266/2.7.3/cores/esp8266/core_esp8266_main.cpp line 119
0x402081fa: __delay(unsigned long) at /Users/wcooke/Library/Arduino15/packages/esp8266/hardware/esp8266/2.7.3/cores/esp8266/core_esp8266_wiring.cpp line 54
0x40203388: WiFiClient::connect(IPAddress, unsigned short) at /Users/wcooke/Library/Arduino15/packages/esp8266/hardware/esp8266/2.7.3/libraries/ESP8266WiFi/src/include/ClientContext.h line 144
0x4020bc7d: BearSSL::WiFiClientSecure::connect(char const*, unsigned short) at /Users/wcooke/Library/Arduino15/packages/esp8266/hardware/esp8266/2.7.3/libraries/ESP8266WiFi/src/WiFiClientSecureBearSSL.cpp line 229
0x40204b89: HTTPClient::connect() at /Users/wcooke/Library/Arduino15/packages/esp8266/hardware/esp8266/2.7.3/libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.cpp line 1235
0x40206ad5: String::invalidate() at /Users/wcooke/Library/Arduino15/packages/esp8266/hardware/esp8266/2.7.3/cores/esp8266/WString.cpp line 140
0x4020581f: HTTPClient::sendRequest(char const*, unsigned char const*, unsigned int) at /Users/wcooke/Library/Arduino15/packages/esp8266/hardware/esp8266/2.7.3/libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.cpp line 681
0x4010071f: umm_free_core(void*) at /Users/wcooke/Library/Arduino15/packages/esp8266/hardware/esp8266/2.7.3/cores/esp8266/umm_malloc/umm_malloc.cpp line 351
0x401009a7: free(void*) at /Users/wcooke/Library/Arduino15/packages/esp8266/hardware/esp8266/2.7.3/cores/esp8266/umm_malloc/umm_malloc.cpp line 398
0x40206ff0: String::operator=(__FlashStringHelper const*) at /Users/wcooke/Library/Arduino15/packages/esp8266/hardware/esp8266/2.7.3/cores/esp8266/WString.cpp line 294
0x4020598a: HTTPClient::GET() at /Users/wcooke/Library/Arduino15/packages/esp8266/hardware/esp8266/2.7.3/libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.cpp line 601
0x40203fd2: InfluxDBClient::validateConnection() at /Users/wcooke/Documents/Arduino/libraries/ESP8266_Influxdb/src/InfluxDbClient.cpp line 516
0x40206644: Print::println(__FlashStringHelper const*) at /Users/wcooke/Library/Arduino15/packages/esp8266/hardware/esp8266/2.7.3/cores/esp8266/Print.cpp line 178
0x40201238: setup() at /Users/wcooke/Documents/Arduino/anais/anais.ino line 63
0x40207aec: loop_wrapper() at /Users/wcooke/Library/Arduino15/packages/esp8266/hardware/esp8266/2.7.3/cores/esp8266/core_esp8266_main.cpp line 194

I'm using library version: 3.3.0
ESP8266 SDK version: 2.7.3

Checking the SDK version prompted me to upgrade it to 2.7.4 and now it's working reliably.

I think this issue can be closed, sorry about that.

If I can recreate the problem I will open a new issue with the decoded exceptions attached.

@vlastahajek
Copy link
Collaborator

Thanks for the update. I haven't tested the latest updates (2.7.3, 2.7.4). It seems this issue was fixed by Esp8266 Arduino #7478.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants