ESP32 BLE_client example code results in "Stack smashing protect failure!" error

Hello Everyone! I've been working on a project involving connecting a pulse oximeter (Brand: Jumper JPD-500G) to an ESP32 board (WEMOS D1 R32 brand ordered from HiLetgo on Amazon). In the Arduino IDE I identified my ESP32 board as a "WEMOS D1 MINI ESP32." I don't know if this is would cause issues, but it is the closest I could find to the actual board name.

I have been testing the two devices with the basic BLE_client example code included in the ESP32_BLE_Arduino library. I have not made any changes to the code, and everything compiles and uploads without issue. When I open the Serial Monitor, it finds the oximeter, connects to it, then gives me the error "Stack smashing protect failure!" and terminates the program and resets the board.

I've included everything sent to the serial monitor, from start until rebooting after failure, below (It is picking up a few extra bluetooth devices, I am connecting to the one titled "My Oximeter").
The BLE_client code is included as an attachment, as it causes the post to exceed the character limit.

18:35:34.999 -> ets Jun  8 2016 00:22:57
18:35:34.999 -> 
18:35:34.999 -> rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
18:35:34.999 -> configsip: 0, SPIWP:0xee
18:35:34.999 -> clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
18:35:34.999 -> mode:DIO, clock div:1
18:35:34.999 -> load:0x3fff0018,len:4
18:35:34.999 -> load:0x3fff001c,len:1044
18:35:34.999 -> load:0x40078000,len:10124
18:35:34.999 -> load:0x40080400,len:5856
18:35:34.999 -> entry 0x400806a8
18:35:35.360 -> Starting Arduino BLE Client application...
18:35:36.172 -> BLE Advertised Device found: Name: , Address: 13:15:11:e3:16:e1, manufacturer data: 0600010f200294caffd4d64abc7d0be40d8d4919c494150c87a86ee351
18:35:36.252 -> BLE Advertised Device found: Name: , Address: 3e:f2:c0:47:67:a4, serviceUUID: 0000fd6f-0000-1000-8000-00805f9b34fb
18:35:36.452 -> BLE Advertised Device found: Name: Versa Lite, Address: ea:c4:83:9a:c3:e3, serviceUUID: abbaff00-e56a-484c-b832-8b17cf6cbfe8, txPower: -21
18:35:37.052 -> BLE Advertised Device found: Name: , Address: 0d:91:e2:84:28:54, serviceUUID: 0000fd6f-0000-1000-8000-00805f9b34fb
18:35:37.092 -> BLE Advertised Device found: Name: My Oximeter, Address: 40:2e:71:46:6b:db, manufacturer data: 402e71466bdb, serviceUUID: cdeacb80-5235-4c07-8846-93a37ee6b86d, txPower: 0
18:35:37.092 -> Forming a connection to 40:2e:71:46:6b:db
18:35:37.092 ->  - Created client
18:35:37.532 ->  - Connected to server
18:35:38.575 ->  - Found our service
18:35:38.575 -> 
18:35:38.575 -> Stack smashing protect failure!
18:35:38.575 -> 
18:35:38.575 -> abort() was called at PC 0x40160e1f on core 1
18:35:38.575 -> 
18:35:38.575 -> ELF file SHA256: 0000000000000000
18:35:38.575 -> 
18:35:38.575 -> Backtrace: 0x4008ec74:0x3ffc7f60 0x4008eef1:0x3ffc7f80 0x40160e1f:0x3ffc7fa0 0x400d53b6:0x3ffc7fc0 0x400d53de:0x3ffc8080 0x400d19c9:0x3ffc80e0 0x400d1aee:0x3ffc8130 0x400d769c:0x3ffc81a0 0x4008ff66:0x3ffc81c0
18:35:38.614 -> 
18:35:38.614 -> Rebooting...

Is the "stack smashing protect failure!" error something that would come up from an error in the code, or do I have an issue with my board/oximeter? I appreciate any help with this issue.

BLE_client.ino (5.67 KB)

Try using the ESP error decoder. Install it,rerun the IDE and copy paste the line:

Backtrace: 0x4008ec74:0x3ffc7f60 0x4008eef1:0x3ffc7f80 0x40160e1f:0x3ffc7fa0 0x400d53b6:0x3ffc7fc0 0x400d53de:0x3ffc8080 0x400d19c9:0x3ffc80e0 0x400d1aee:0x3ffc8130 0x400d769c:0x3ffc81a0 0x4008ff66:0x3ffc81c0

and see what it tells you.

Decoding stack results
0x4008ec74: invoke_abort at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/esp32/panic.c line 156
0x4008eef1: abort at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/esp32/panic.c line 171
0x40160e1f: __stack_chk_fail at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/esp32/stack_check.c line 36
0x400d53b6: BLERemoteService::retrieveCharacteristics() at C:\Users\flygu\OneDrive\Documents\Arduino\libraries\ESP32_BLE_Arduino\src\BLERemoteService.cpp line 216
0x400d53de: BLERemoteService::getCharacteristic(BLEUUID) at C:\Users\flygu\OneDrive\Documents\Arduino\libraries\ESP32_BLE_Arduino\src\BLERemoteService.cpp line 149
0x400d19c9: connectToServer() at C:\Users\flygu\AppData\Local\Temp\arduino_modified_sketch_415405/BLE_client.ino line 70
0x400d1aee: loop() at C:\Users\flygu\AppData\Local\Temp\arduino_modified_sketch_415405/BLE_client.ino line 139
0x400d769c: loopTask(void*) at C:\Users\flygu\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.6\cores\esp32\main.cpp line 23
0x4008ff66: vPortTaskWrapper at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/port.c line 143

Here is what I get from the ESP error decoder. I don't have much experience with coding/debugging, I'd appreciate any help understanding how I can use this info.
Should I be editing stuff in the other files mentioned to fix the issue?

I believe I found the issue. The board connects to another device perfectly fine, so the issue is with the pulse oximeter and not with the code/board

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.