espressif / arduino-esp32

Arduino core for the ESP32
GNU Lesser General Public License v2.1
13.47k stars 7.38k forks source link

BLE stack corruption calling esp_ble_gattc_get_attr_count #3631

Closed paulelong closed 4 years ago

paulelong commented 4 years ago

Hardware:

Board: ?ESP32 Dev Module? ?node32? ?ttgo_lora? I (31) boot: ESP-IDF v4.1-dev-1795-gca8fac876 2nd stage bootloader I (31) boot: compile time 16:45:55 I (31) boot: chip revision: 1 I (35) boot.esp32: SPI Speed : 40MHz I (40) boot.esp32: SPI Mode : DIO I (44) boot.esp32: SPI Flash Size : 2MB

Core Installation version: Not sure how to easily get this info. IDE name: VSCode Upload Speed: 115200 Computer OS: Windows 10

Description:

I'm using BLE to communicate as a server to multiple BLE peripherals. When I call esp_ble_gattc_get_attr_count, I would sometimes get stack corruption. It depends on how/where I defined a local variable. The other symptom of this problem is that the local variable was initialized to 1, and reset to 0 afterwards.

I believe the issue is that it's accepts an int8 as an arg, but then casts as a int. If I make this code change it fixes my problem:

''' --- a/components/bt/host/bluedroid/btc/profile/std/gatt/btc_gattc.c +++ b/components/bt/host/bluedroid/btc/profile/std/gatt/btc_gattc.c @@ -551,12 +551,15 @@ esp_gatt_status_t btc_ble_gattc_get_attr_count(uint16_t conn_id, uint16_t char_handle, uint16_t *count) {

I believe this problem is in other places, though haven't tried to search.

stale[bot] commented 4 years ago

[STALE_SET] This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. Thank you for your contributions.

stale[bot] commented 4 years ago

[STALE_DEL] This stale issue has been automatically closed. Thank you for your contributions.