oscaracena / pygattlib

Other
62 stars 12 forks source link

Deadlock in recently added gattrib.c mutex #12

Closed iosabi closed 3 years ago

iosabi commented 3 years ago

I'm experiencing a deadlock when receiving an indication from a connected BLE devices.

The traces is as follows:

I tried releasing the lock and re-acquiring the lock before/after calling evt->func and that worked for my case, but I don't know whether that's the right solution. This deadlock was introduced by #11.

References: https://github.com/oscaracena/pygattlib/blob/7cdeceb9e46f1aa70e28e5f3f861875685bc1cd9/src/gattlib.cpp#L291

https://github.com/oscaracena/pygattlib/blob/7cdeceb9e46f1aa70e28e5f3f861875685bc1cd9/src/bluez/attrib/gattrib.c#L479

iosabi commented 3 years ago

@jsgh FYI

jsgh commented 3 years ago

Aye, indications can do that. So could notifications in theory, if the on_notification handler attempts to, say, read an attrib from within the handler.

13 should fix it.

oscaracena commented 3 years ago

@jsgh, @iosabi Thanks for your hard work! :)