Skip to content

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

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
sepp89117 opened this issue Jun 24, 2022 · 3 comments
Labels
Area: BT&Wifi BT & Wifi related issues

Comments

@sepp89117
Copy link

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!

@github-actions github-actions bot changed the title Stack canary watchpoint triggered (btController) -> vTaskSwitchContext -> /freertos/tasks.c line 3435 Stack canary watchpoint triggered (btController) -> vTaskSwitchContext -> /freertos/tasks.c line 3435 (IDFGH-7683) Jun 24, 2022
@Alvin1Zhang Alvin1Zhang transferred this issue from espressif/esp-idf Jun 27, 2022
@Alvin1Zhang
Copy link
Collaborator

Moved Arduino issue tracker. Thanks.

@VojtechBartoska VojtechBartoska added Area: BT&Wifi BT & Wifi related issues Status: Awaiting triage Issue is waiting for triage and removed Status: Opened labels Jun 27, 2022
@TheHolyRoger
Copy link

I believe this was fixed in espressif/esp-idf@66a01ef

Related to espressif/esp-idf#4719

So fixed in ESP-IDF version 5.1 but unfortunately we're stuck on version 4.4.99 in Arduino:
https://github.com/espressif/arduino-esp32/blob/master/CMakeLists.txt#L9

@Parsaabasi Parsaabasi removed the Status: Awaiting triage Issue is waiting for triage label Jan 16, 2025
@Parsaabasi
Copy link

Hello,

Due to the overwhelming volume of issues currently being addressed, we have decided to close the previously received tickets. If you still require assistance or if the issue persists, please don't hesitate to reopen the ticket.

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: BT&Wifi BT & Wifi related issues
Projects
None yet
Development

No branches or pull requests

6 participants