-
-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pybricks.common.ble: fix data consistency when observing
In the `ble` module, we maintain a copy of observed advertisement data that is updated during servicing of PBIO (contiki) events. These events can be triggered any time the GC is invoked, e.g. during allocation of memory for MicroPython objects. In pb_module_ble_observe(), we were iterating over the observed data and allocating new MicroPython objects for each item which could trigger PBIO events to be run resulting in the observed data being modified while we are still iterating over it. This could result in a crash, the most likely of which is raising an exception for an invalid data type. We can avoid this by making a copy of the data before iterating over it. Fixes: pybricks/support#1278
- Loading branch information
Showing
2 changed files
with
17 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters