Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

deleting BLEClient is not safe #4047

Copy link
Copy link
Closed
Closed
Copy link
@jackjansen

Description

@jackjansen
Issue body actions

My BLE client code was structured more-or-less as

BLEClient *client = new BLEClient();
client->connect(address, type);
// interact with client
client->disconnect();
delete client;

but this is unsafe. Sometimes I get a corrupted heap, sometimes I get other crashes, possibly after running this code again (I am creating many connections to many BLE devices over a long time).

I think the problem may be that disconnect() is asynchronous, because often my crashes are in BLEClient::gattClientEventHandler() in the ESP_GATTC_DISCONNECT_EVT case handler, but they can also happen in the BLE thread, or in completely unrelated code.

The workaround I have is to never delete my BLEClient objects but to cache and reuse them, but from the code (and the minimal documentation) it seems like I should have been able to create and delete them on-the-fly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Status: StaleIssue is stale stage (outdated/stuck)Issue is stale stage (outdated/stuck)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.