Closed SomberNight closed 1 year ago
@SomberNight
Have you tried the latest cython-hidapi which uses hidapi 0.13.1 release?
I have just tested with hidapi==0.13.1
on a x86_64 macOS 12.5 vm. Can still reproduce.
And btw here is the "report" from the macOS built-in crash reporter that it wants to send to the mothership (Apple):
I can confirm the reproducer crashes under my Mac Mini M1 (2020 model) running latest macOS Ventura 13.3.1.
And with PR #150, it no longer crashes.
On macOS, when using hidapi in a thread other than the main thread, during shutdown of the python process, the application segfaults. AFAICS, depending on the macOS version, it might be a SIGILL or a SIGSEGV.
I've tested on macOS 10.15.3, 11.3, and 12.5, and all exhibit the issue. Also tested on recent Ubuntu and Win10, both look unaffected.
All recent hidapi releases are affected since 0.11.0 (so last one that works well is 0.10.1).
Simple test case script:
After running script, OS crash reporter window pops up:
macOS crash reporter. "Python quit unexpectedly"
![pic1](https://user-images.githubusercontent.com/29142493/182931792-5156257f-a884-487b-84fc-28ecf7289299.png)https://github.com/trezor/cython-hidapi/issues/128 and https://github.com/trezor/cython-hidapi/pull/130 look potentially related.
hidapi 0.10.1 works well
``` (env) user@users-iMac tmp % pip install "hidapi==0.10.1" Collecting hidapi==0.10.1 Using cached hidapi-0.10.1-cp39-cp39-macosx_10_9_x86_64.whl (45 kB) Requirement already satisfied: setuptools>=19.0 in ./env/lib/python3.9/site-packages (from hidapi==0.10.1) (63.4.1) Installing collected packages: hidapi Successfully installed hidapi-0.10.1 (env) user@users-iMac tmp % python3 f2.py [{'path': b'IOService:/AppleACPIPlatformExpert/[... SNIP ...], 'usage_page': 1, 'usage': 1, 'interface_number': 0}] (env) user@users-iMac tmp % pip uninstall hidapi Found existing installation: hidapi 0.10.1 Uninstalling hidapi-0.10.1: Would remove: /Users/user/wspace/tmp/env/lib/python3.9/site-packages/hid.cpython-39-darwin.so /Users/user/wspace/tmp/env/lib/python3.9/site-packages/hidapi-0.10.1.dist-info/* Proceed (Y/n)? Y Successfully uninstalled hidapi-0.10.1 ```With hidapi 0.11.0+, note the
zsh: illegal hardware instruction
linehidapi==0.11.0
``` (env) user@users-iMac tmp % pip install "hidapi==0.11.0" Collecting hidapi==0.11.0 Using cached hidapi-0.11.0-cp39-cp39-macosx_10_9_x86_64.whl (48 kB) Requirement already satisfied: setuptools>=19.0 in ./env/lib/python3.9/site-packages (from hidapi==0.11.0) (63.4.1) Installing collected packages: hidapi Successfully installed hidapi-0.11.0 (env) user@users-iMac tmp % python3 f2.py [{'path': b'IOService:/AppleACPIPlatformExpert/[... SNIP ...], 'usage_page': 1, 'usage': 1, 'interface_number': 0}] zsh: illegal hardware instruction python3 f2.py (env) user@users-iMac tmp % pip uninstall hidapi Found existing installation: hidapi 0.11.0 [... SNIP ...] Successfully uninstalled hidapi-0.11.0 ```hidapi==0.11.0.post2
``` (env) user@users-iMac tmp % pip install "hidapi==0.11.0.post2" Collecting hidapi==0.11.0.post2 Downloading hidapi-0.11.0.post2-cp39-cp39-macosx_10_9_x86_64.whl (48 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 48.3/48.3 kB 1.6 MB/s eta 0:00:00 Requirement already satisfied: setuptools>=19.0 in ./env/lib/python3.9/site-packages (from hidapi==0.11.0.post2) (63.4.1) Installing collected packages: hidapi Successfully installed hidapi-0.11.0.post2 (env) user@users-iMac tmp % python3 f2.py [{'path': b'IOService:/AppleACPIPlatformExpert/[... SNIP ...], 'usage_page': 1, 'usage': 1, 'interface_number': 0}] zsh: illegal hardware instruction python3 f2.py (env) user@users-iMac tmp % pip uninstall hidapi Found existing installation: hidapi 0.11.0.post2 [... SNIP ...] Successfully uninstalled hidapi-0.11.0.post2 ```hidapi==0.11.2
``` (env) user@users-iMac tmp % pip install "hidapi==0.11.2" Collecting hidapi==0.11.2 Using cached hidapi-0.11.2-cp39-cp39-macosx_10_9_x86_64.whl (57 kB) Requirement already satisfied: setuptools>=19.0 in ./env/lib/python3.9/site-packages (from hidapi==0.11.2) (63.4.1) Installing collected packages: hidapi Successfully installed hidapi-0.11.2 (env) user@users-iMac tmp % python3 f2.py [{'path': b'DevSrvsID:4294967951', 'vendor_id': 33006, [... SNIP ...], 'usage_page': 1, 'usage': 6, 'interface_number': 0}] zsh: illegal hardware instruction python3 f2.py (env) user@users-iMac tmp % pip uninstall hidapi Found existing installation: hidapi 0.11.2 [... SNIP ...] Successfully uninstalled hidapi-0.11.2 ```hidapi==0.12.0.post2
``` (env) user@users-iMac tmp % pip install "hidapi==0.12.0.post2" Collecting hidapi==0.12.0.post2 Using cached hidapi-0.12.0.post2-cp39-cp39-macosx_10_9_x86_64.whl (57 kB) Requirement already satisfied: setuptools>=19.0 in ./env/lib/python3.9/site-packages (from hidapi==0.12.0.post2) (63.4.1) Installing collected packages: hidapi Successfully installed hidapi-0.12.0.post2 (env) user@users-iMac tmp % python3 f2.py [{'path': b'DevSrvsID:4294967951', 'vendor_id': 33006, [... SNIP ...], 'usage_page': 1, 'usage': 6, 'interface_number': 0}] zsh: illegal hardware instruction python3 f2.py (env) user@users-iMac tmp % ```