Board
Heltec WiFi LoRa 32 V3
Device Description
n/a - purely software issue
Hardware Configuration
N/A - purely software issue
Version
latest master (checkout manually)
Type
Bug
IDE Name
n/a
Operating System
n/a
Flash frequency
n/a
PSRAM enabled
yes
Upload speed
n/a
Description
Context: #12533
As I'm studying Arduino BLE code, I'm realizing that maybe there is a thread safety issue. Variables like BLEServer::m_connectedServersMap (
|
std::map<uint16_t, conn_status_t> m_connectedServersMap; |
) are accessed from both the NimBLE thread (BLEServer::handleGATTServerEvent -> addPeerDevice) and the main thread (BLEServer::getPeerDevices) without synchronization. Maybe in practice in most cases this works. But technically speaking, this is a data race and in theory can cause very spooky crashes and unexpected behavior.
I see thread safety is referenced briefly in #9878 (comment).
This issue also seems present in historical NimBLE, it is not new to Arduino BLE.
FYI @lucasssvaz
cc @vidplace7
Sketch
n/a - probably difficult to reproduce
Debug Message
Other Steps to Reproduce
No response
I have checked existing issues, online documentation and the Troubleshooting Guide
Board
Heltec WiFi LoRa 32 V3
Device Description
n/a - purely software issue
Hardware Configuration
N/A - purely software issue
Version
latest master (checkout manually)
Type
Bug
IDE Name
n/a
Operating System
n/a
Flash frequency
n/a
PSRAM enabled
yes
Upload speed
n/a
Description
Context: #12533
As I'm studying Arduino BLE code, I'm realizing that maybe there is a thread safety issue. Variables like BLEServer::m_connectedServersMap (
arduino-esp32/libraries/BLE/src/BLEServer.h
Line 217 in 494670d
I see thread safety is referenced briefly in #9878 (comment).
This issue also seems present in historical NimBLE, it is not new to Arduino BLE.
FYI @lucasssvaz
cc @vidplace7
Sketch
Debug Message
Other Steps to Reproduce
No response
I have checked existing issues, online documentation and the Troubleshooting Guide