-
Notifications
You must be signed in to change notification settings - Fork 7.4k
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
Kernel panic when delete BLEClient object with descriptor characteristic #8010
Conversation
Fix kernel panic issue when trying to release BLEClient when the target device have a ble descriptor.
@chesterkwan - Thanks for the PR! |
Any updates on this @chesterkwan ? |
Thanks for reminding me of the pull request, too busy on other projects and nearly forgot about it. The following section is callback class to handle the connect and disconnect of the BLE device. The faulty condition is that when you try to disconnect a device with write or notify characteristic, it will cause a kernel panic. But if you try to disconnect a device only with read characteristic, everything goes fine. After drilling into the library, and find out the write and notify both characteristic include a descriptor. And the kernel panic were caused by the code trying to remove an item which have already been removed. Thanks
|
Any comment? |
Sorry is there any question regarding this pull request? |
Hi @chesterkwan, not right now, it's awaiting the review from our side. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Just a small suggestion.
Co-authored-by: Lucas Saavedra Vaz <[email protected]>
Committed. Thanks |
Fix kernel panic issue when trying to release BLEClient when the target device have a ble descriptor.
Description of Change
When I try to release BLEClient to free memory, sometimes it causes a kernel panic. After tracing down the code, I discover that when it try to delete the characteristic map of the BLEClient, it will also have to remove the descriptors under it if it exists.
When removing the descriptor from the map in BLERemoteCharacteristic::removeDescriptors() function, the code will first remove the map entry and then will try to access that deleted entry to remove the descriptor object. Which caused the kernel panic as entry are not exist.
The fix is simply removing the line which remove the map entry, and let the following code to remove then descriptor object. The final clear after the for-loop will ensure the map being cleared.
Tests scenarios
Tested on ESP32C3 and ESP32