hoberman / Victron_BLE_Advertising_example

12 stars 2 forks source link

Debug exception reason: Stack canary watchpoint triggered (IDLE) #2

Closed jamiehoward430 closed 11 months ago

jamiehoward430 commented 11 months ago

Hi,

Thanks for this example.

Trying to use your code and keep getting the below error, what version ESP are you using?

17:07:05.931 -> Guru Meditation Error: Core  1 panic'ed (Unhandled debug exception). 
17:07:05.931 -> Debug exception reason: Stack canary watchpoint triggered (IDLE) 

I have managed to trace it to this function, just not sure why it keeps crashing, hoping to expand on this for my DC-DC charger and BMV too once I get this bit working :)

status = esp_aes_crypt_ctr(&ctx, encrDataSize, &nonce_offset, nonce_counter, stream_block, inputData, outputData);

hoberman commented 11 months ago

I'm away from my hardware tonight so I don't have the specifics of the board where I did my development. I'll take a look at it as soon as I get a chance and I'll let you know what I find out. Editorial comment: I wish naming of ESP32 variants would be more consistent/obvious/easy-to-follow.

In the meantime, you might add some code to verify that the encrDataSize fed into the decrypt call is positive/reasonable. My example is meant to be the minimum necessary to get results so it doesn't include much in the way of checks to detect data corruption, etc., and I can imagine scenarios where that could cause things to blow up.

Keep in mind that if you put any diagnostic prints before the call that causes the panic, you'll probably need to insert a delay(1000) call to let the serial data display before the panic happens.

jamiehoward430 commented 11 months ago

I got to the bottom of it, I had to change a couple of lines in BLE_Adv_Callback.ino as below

Line 22 from String manData = advertisedDevice.getManufacturerData(); to std::string manData = advertisedDevice.getManufacturerData();

and Line 27 from manData.toCharArray((char *)manCharBuf,manDataSize+1); to manData.copy((char *)manCharBuf, manDataSize + 1);

hoberman commented 11 months ago

I got to the bottom of why you and another poster had to make changes related to the use of String vs std::string. It looks like I was using 3.x (beta?) version of ESP32 libraries and Espressif has apparently changed the type for getManufacturerData() (and others) in their code. You're probably going to run into that when the updated version of their library hits your system.

I've updated my GitHub repository to include notes about that and a #define to allow customizing of the demo code to accomodate the change.