Skip to content

Stack canary watchpoint triggered (btController) -> vTaskSwitchContext -> /freertos/tasks.c line 3435 (IDFGH-7683) #6915

Closed
@sepp89117

Description

@sepp89117

Hi, please help to solve my problem.

I use ESP32 Dev Module
I have esp32 Version 2.0.3 installed
I use WiFi and BLE together
Sometimes is working fine

Code snippet:

#include <WiFi.h>
#include <WiFiClient.h>
#include <WebServer.h>
#include <ESPmDNS.h>
#include "BLEDevice.h"

WebServer server(80);

struct GoProCam {
  BLEAdvertisedDevice* pDevice = nullptr;
  BLEClient* pClient = nullptr;
  bool toConnect = false;
  bool isAuth = false;
  bool isConnected = false;
  uint32_t lastKeepAlive = 0;
  char lastCommand[2] = {0, 0};
  char lastError[2] = {0, 0};
  BLERemoteCharacteristic* pCommandCharacteristic = nullptr;
  BLERemoteCharacteristic* pCommandRespCharacteristic = nullptr;
  BLERemoteCharacteristic* pSettingsCharacteristic = nullptr;
  BLERemoteCharacteristic* pSettingsRespCharacteristic = nullptr;
};

//... some more variables

bool connectToCam(uint8_t camIndex) {
// Set security
  BLEDevice::setEncryptionLevel(ESP_BLE_SEC_ENCRYPT);
  BLEDevice::setSecurityCallbacks(new MySecurity());
  BLESecurity *pSecurity = new BLESecurity();
  pSecurity->setAuthenticationMode(ESP_LE_AUTH_REQ_SC_BOND); //ESP_LE_AUTH_REQ_SC_ONLY
  pSecurity->setCapability(ESP_IO_CAP_OUT);
  pSecurity->setRespEncryptionKey(ESP_BLE_ENC_KEY_MASK | ESP_BLE_ID_KEY_MASK);

// Create client
  goProCams[camIndex].pClient = BLEDevice::createClient();
  goProCams[camIndex].pClient->setClientCallbacks(new MyClientCallback());

  goProCams[camIndex].pClient->connect(goProCams[camIndex].pDevice); 

//here fires BLESecurityCallbacks -> onAuthenticationComplete() = successful

//[BUG] Stack canary watchpoint triggered (btController)
  BLERemoteService* pRemoteService = goProCams[camIndex].pClient->getService(controlServiceUUID);

  //... nothing more executed
}

void setup() {
  Serial.begin(115200);
  
  WiFi.softAP(ssid, password);

  if (MDNS.begin(DomainName)) {
    Serial.println("MDNS responder started");
    MDNS.addService("http", "tcp", 80);
  }
  
  initServer(); //server.on()...
  
  BLEDevice::init(ssid);
  BLEScan* pBLEScan = BLEDevice::getScan();
  pBLEScan->setAdvertisedDeviceCallbacks(new MyAdvertisedDeviceCallbacks());
  pBLEScan->setActiveScan(true);
  pBLEScan->start(5);
}

void loop() {
  BLEDevice::getScan()->clearResults();

  server.handleClient();
  vTaskDelay(2);

  for (uint8_t i = 0; i < maxCams; i++) {
    if (goProCams[i].pDevice != nullptr) {
      if (goProCams[i].toConnect) {
        if (connectToCam(i)) {
          goProCams[i].isConnected = true;
          //...
        }
      }
    }
  }
}

Exception:

Guru Meditation Error: Core  0 panic'ed (Unhandled debug exception). 
Debug exception reason: Stack canary watchpoint triggered (btController) 
Core  0 register dump:
PC      : 0x40094991  PS      : 0x00060036  A0      : 0x40092e07  A1      : 0x3ffe1bb0  
A2      : 0x3ffc4bf4  A3      : 0x3ffc4c1c  A4      : 0x3ffc4c1c  A5      : 0x00000001  
A6      : 0x00000000  A7      : 0x00000017  A8      : 0x3ffc4bfc  A9      : 0x3ffe1b90  
A10     : 0x3ffdb96c  A11     : 0x3ffdb96c  A12     : 0x00000014  A13     : 0x00000000  
A14     : 0x3ffdb964  A15     : 0x80000001  SAR     : 0x00000008  EXCCAUSE: 0x00000001  
EXCVADDR: 0x00000000  LBEG    : 0x40090588  LEND    : 0x4009059e  LCOUNT  : 0xffffffff  


Backtrace:0x4009498e:0x3ffe1bb00x40092e04:0x3ffe1be0 0x40092db4:0xa5a5a5a5  |<-CORRUPTED

Decoding stack results

0x4009498e: vTaskSwitchContext at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/tasks.c line 3435

Thank you!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions