-
Notifications
You must be signed in to change notification settings - Fork 205
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
Crash when calling enumerate
from different threads (not simultaneously) - arm64 macOS
#659
Comments
AFAIk hidapi is not thread-safe on neither of supported platforms |
Do you have any links/documentation where they talk about thread safety? I find it very weird that it crashes even when the threads are properly synchronized. And it only happens in one specific os/arch combination, not on x86 macos or arm linux. |
Hm, I might be wrong. I only found this 11 years old comment: signal11/hidapi#56 (comment)
|
@afilini do you see the same failure with the following code? import hid
import threading
def e():
m.acquire()
print(hid.enumerate())
m.release()
m = threading.Lock()
a = threading.Thread(target=e, args=())
b = threading.Thread(target=e, args=())
c = threading.Thread(target=e, args=())
a.start()
b.start()
c.start()
a.join()
b.join()
c.join() If yes, we can close this issue and open a new one in https://github.com/trezor/cython-hidapi because the issue is not in hwi but rather in cython-hidapi. |
Yep, same issue |
Closing as this is an usptream issue. |
Created trezor/cython-hidapi#148 to continue there |
The following python script should make the interpreter crash when run on a mac M1. This has been tested with multiple python3 versions (if i remember correctly 3.9, 3.10 and 3.11).
It seems to be working fine on x86 macos (at least in the VM I use to test).
Essentially, calling
enumerate
from different threads that are correctly synchronized using a mutex causes the crash. See the example code here:I had it work a couple of times, but the vast majority of times it will crash in the same way, somewhere in the CoreFoundation os lib.
Debugger backtrace
The text was updated successfully, but these errors were encountered: