Skip to content

InstrFetchProhibited/IllegalInstruction on X509 cert verification #861

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

Closed
tedder opened this issue Nov 23, 2017 · 7 comments
Closed

InstrFetchProhibited/IllegalInstruction on X509 cert verification #861

tedder opened this issue Nov 23, 2017 · 7 comments
Labels
Status: Stale Issue is stale stage (outdated/stuck)

Comments

@tedder
Copy link
Contributor

tedder commented Nov 23, 2017

Hardware:

Board: Sparkfun dev board, DOIT kit
Core Installation/update date: 10 Nov 2017
IDE name: Arduino IDE
Flash Frequency: 80Mhz
Upload Speed: 115200, 921600

libraries

Description:

X509 certificate connections crash the board with InstrFetchProhibited (sparkfun) or IllegalInstruction (DOIT). It seems maybe this is a cross-core communication issue, given that wifi is on core0 and the code runs on core1?

I'm not confident with opening this here nor in Pubsubclient, but I think it fits here much better.

I don't think it's a WDT issue, based on the trace.

Noting #657, as shown in the commit above it isn't the small mem/stack issue in there, also noting pubsubclient #84. Both are similar but I don't think they have the same root cause.

Sketch:

Snippet. I can give a full example if it helps.

    espClient.setCertificate(__9a4_public_bin_key);
    espClient.setPrivateKey(__9a4private_bin_key);
    client.setServer(mqtt_server, 8883);


  while (!client.connected()) {
    Serial.println("Attempting MQTT connection...");
    // Create a random client ID
    String clientId = "ESP32Client-";
    clientId += String(random(0xffff), HEX);
    Serial.print("clientid: ");
    Serial.println(clientId.c_str());
    // Attempt to connect
    if (client.connect(clientId.c_str())) { // crashes here (this is line 65)

Debug Messages:

Sparkfun doesn't have the debug menu, but the DOIT does. However I didn't see any more debugging in the logs even with "core debug level=debug".

errors

first, the decoded exception:

Decoding 8 results
0x400d2120: PubSubClient::readPacket(unsigned char*) at /Users/ted/Documents/Arduino/libraries/pubsubclientdiegopx/src/PubSubClient.cpp line 706
0x400d23a8: PubSubClient::connect(char const*, char const*, char const*, char const*, unsigned char, bool, char const*) at /Users/ted/Documents/Arduino/libraries/pubsubclientdiegopx/src/PubSubClient.cpp line 706
0x400d2436: PubSubClient::connect(char const*) at /Users/ted/Documents/Arduino/libraries/pubsubclientdiegopx/src/PubSubClient.cpp line 706
0x400d1e8b: reconnect() at /Users/ted/Documents/Arduino/esp32_mqtt/esp32_mqtt.ino line 65
0x400d1feb: loop() at /Users/ted/Documents/Arduino/esp32_mqtt/esp32_mqtt.ino line 151
0x40134e5c: loopTask(void*) at /Applications/Arduino_183.app/Contents/Java/hardware/espressif/esp32/cores/esp32/main.cpp line 18 (discriminator 1)

and the guru exception:

Guru Meditation Error of type InstrFetchProhibited occurred on core  1. Exception was unhandled.
Register dump:
PC      : 0x0d2dfc40  PS      : 0x00060430  A0      : 0x800d2123  A1      : 0x3ffd5c10  
A2      : 0x3ffc32e8  A3      : 0x3ffd5c32  A4      : 0x0d2dfc40  A5      : 0x000031af  
A6      : 0x3f401079  A7      : 0x3f401c03  A8      : 0x800d20c9  A9      : 0x3ffd5bf0  
A10     : 0x3ffc33a4  A11     : 0x3ffc32ec  A12     : 0xffff877f  A13     : 0x000031af  
A14     : 0x3f401079  A15     : 0x0000001d  SAR     : 0x00000008  EXCCAUSE: 0x00000014  
EXCVADDR: 0x0d2dfc40  LBEG    : 0x4000c46c  LEND    : 0x4000c477  LCOUNT  : 0x00000000  

Backtrace: 0x0d2dfc40:0x3ffd5c10 0x400d2120:0x3ffd5c30 0x400d23a8:0x3ffd5c70 0x400d2436:0x3ffd5cb0 0x400d1e8b:0x3ffd5ce0 0x400d1feb:0x3ffd5d20 0x40134e5c:0x3ffd5d60
@copercini
Copy link
Contributor

copercini commented Nov 23, 2017

espClient.setCertificate(__9a4_public_bin_key);

try with your certificate, not the public key, also enable verbose debug level (in Arduino menu) to see what is happening

@tedder
Copy link
Contributor Author

tedder commented Nov 23, 2017

I actually swapped the cert, just didn't rename the variable, in the above. Here's the first few lines showing that:

const char* __9a4_public_bin_key = \
  "-----BEGIN CERTIFICATE-----\n" \

For verbose debugging, you're talking about tools->core debug level, yes? I put notes for that above. If there's some other way, let me know.

@copercini
Copy link
Contributor

copercini commented Nov 23, 2017

I actually swapped the cert, just didn't rename the variable, in the above.

ok, right

For verbose debugging, you're talking about tools->core debug level, yes?

yep, I think just "ESP32 Dev Module" have this option

@tedder
Copy link
Contributor Author

tedder commented Nov 26, 2017

FWIW, I read the diffs of #865 and reran. Still failing.

Guru Meditation Error: Core  1 panic'ed (InstrFetchProhibited)
. Exception was unhandled.
Register dump:

@everslick
Copy link
Contributor

@tedder Is this issue still unsolved for you? Do you feel this is a bug in the Arduino core? Can we close this?

@stale
Copy link

stale bot commented Aug 1, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. Thank you for your contributions.

@stale stale bot added the Status: Stale Issue is stale stage (outdated/stuck) label Aug 1, 2019
@stale
Copy link

stale bot commented Aug 15, 2019

This stale issue has been automatically closed. Thank you for your contributions.

@stale stale bot closed this as completed Aug 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Stale Issue is stale stage (outdated/stuck)
Projects
None yet
Development

No branches or pull requests

3 participants