Skip to content
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

Stack Smashing #1194

Open
varun2200 opened this issue Jun 18, 2024 · 3 comments
Open

Stack Smashing #1194

varun2200 opened this issue Jun 18, 2024 · 3 comments

Comments

@varun2200
Copy link

13:36:40.995 -> BLE Advertised Device found: Name: , Address: 4f:94:11:6f:26:4e, manufacturer data: 4c001005229870d425, txPower: 8, rssi: -74
13:36:40.995 -> BLE Advertised Device found: Name: , Address: 06:ad:cd:18:de:2f, manufacturer data: 06000109212a5b65e3ab75c44a6967734c656e6f766f, rssi: -96
13:36:42.531 -> Found our service
13:36:42.531 ->
13:36:42.531 -> Stack smashing protect failure!
13:36:42.531 ->
13:36:42.531 ->
13:36:42.531 -> Backtrace: 0x40082399:0x3ffc84c0 0x4009372d:0x3ffc84e0 0x400823aa:0x3ffc8500 0x400d5e92:0x3ffc8520 0x400d5f91:0x3ffc85c0 0x400d68c7:0x3ffc8610 0x400d69fe:0x3ffc86b0 0x400d235d:0x3ffc8710 0x400d256d:0x3ffc8750 0x400da2e0:0x3ffc8770

the BLE client application is restarting again and again when it attempts to connect to an ios device on which the server is hosted
And there is a stack smashing protect failure
I am not able to find where the issue is.
If the ble library is compatible with ios devices, it should work

@RASPIAUDIO
Copy link

exact same bug here

@RASPIAUDIO
Copy link

downgarded to ESP version 2.0.17 and no more crash but still no notification

@HexfeT78
Copy link

HexfeT78 commented Jun 22, 2024

@varun2200 @RASPIAUDIO

Find the following function in the BLERemoteCharacteristic.cpp file and replace it with it. The problem will be solved.

void BLERemoteCharacteristic::retrieveDescriptors() {
  log_v(">> retrieveDescriptors() for characteristic: %s", getUUID().toString().c_str());

  // Remove any existing descriptors.
  removeDescriptors();  

  uint16_t offset = 0;
  esp_gattc_descr_elem_t result[10];  // Array to hold multiple results.
  while (true) {
    uint16_t count = 10;  // Number of descriptors to retrieve in each call.
    esp_gatt_status_t status = ::esp_ble_gattc_get_all_descr(
      getRemoteService()->getClient()->getGattcIf(), 
      getRemoteService()->getClient()->getConnId(), 
      getHandle(), 
      result, 
      &count, 
      offset
    );

    if (status == ESP_GATT_INVALID_OFFSET) {  // End of the entries.
      break;
    }

    if (status != ESP_GATT_OK) {
      log_e("esp_ble_gattc_get_all_descr: %s", BLEUtils::gattStatusToString(status).c_str());
      break;
    }

    if (count == 0) {
      break;
    }

    for (int i = 0; i < count; i++) {
      log_d("Found a descriptor: Handle: %d, UUID: %s", result[i].handle, BLEUUID(result[i].uuid).toString().c_str());

      BLERemoteDescriptor *pNewRemoteDescriptor = new BLERemoteDescriptor(result[i].handle, BLEUUID(result[i].uuid), this);
      m_descriptorMap.insert(std::pair<String, BLERemoteDescriptor *>(pNewRemoteDescriptor->getUUID().toString(), pNewRemoteDescriptor));
    }

    offset += count;  // Increment the offset by the number of descriptors retrieved.
  }

  log_v("<< retrieveDescriptors(): Found %d descriptors.", m_descriptorMap.size());
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants