HWI
HWI copied to clipboard
HID crashes on MacOS
Hi
I'm building a wallet that depends on HWI to interface with my Trezor device. I use 2.0.2 version and the wallet is running on my person Macbook (Big Sur). It got crash multiple time easily, and here is the error log that shows the crashing Thread:
Thread 4 Crashed:
0 com.apple.CoreFoundation 0x00007fff20576f2e _CFAssertMismatchedTypeID + 110
1 com.apple.CoreFoundation 0x00007fff204200f9 CFRunLoopAddSource + 1019
2 com.apple.framework.IOKit 0x00007fff22b5ab2d IOHIDDeviceScheduleWithRunLoop + 74
3 com.apple.framework.IOKit 0x00007fff22b5ecd2 __IOHIDManagerDeviceApplier + 527
4 com.apple.framework.IOKit 0x00007fff22b22378 __IOHIDManagerDeviceAdded + 766
5 com.apple.framework.IOKit 0x00007fff22b21f81 __IOHIDManagerSetDeviceMatching + 347
6 hid.cpython-38-darwin.so 0x00000001095a5049 hid_enumerate + 425
7 hid.cpython-38-darwin.so 0x00000001095a46bb __pyx_pw_3hid_1enumerate + 459
8 com.apple.python3 0x00000001079f338a cfunction_call_varargs + 122
9 com.apple.python3 0x00000001079f2dd6 _PyObject_MakeTpCall + 374
10 com.apple.python3 0x0000000107ad313c call_function + 652
11 com.apple.python3 0x0000000107acf6d6 _PyEval_EvalFrameDefault + 29782
12 com.apple.python3 0x0000000107ad4097 _PyEval_EvalCodeWithName + 3287
13 com.apple.python3 0x00000001079f390d _PyFunction_Vectorcall + 253
14 com.apple.python3 0x00000001079f614b method_vectorcall + 171
15 com.apple.python3 0x0000000107ad3012 call_function + 354
16 com.apple.python3 0x0000000107acf84e _PyEval_EvalFrameDefault + 30158
17 com.apple.python3 0x00000001079f378d function_code_fastcall + 237
18 com.apple.python3 0x0000000107ad3012 call_function + 354
19 com.apple.python3 0x0000000107acf78a _PyEval_EvalFrameDefault + 29962
20 com.apple.python3 0x0000000107ad4097 _PyEval_EvalCodeWithName + 3287
21 com.apple.python3 0x00000001079f390d _PyFunction_Vectorcall + 253
22 com.apple.python3 0x00000001079f2c0a _PyObject_FastCallDict + 218
23 com.apple.python3 0x00000001079f42f3 _PyObject_Call_Prepend + 131
24 com.apple.python3 0x0000000107a4cb74 slot_tp_init + 180
25 com.apple.python3 0x0000000107a48054 type_call + 292
26 com.apple.python3 0x00000001079f2dd6 _PyObject_MakeTpCall + 374
27 com.apple.python3 0x0000000107ad313c call_function + 652
28 com.apple.python3 0x0000000107acf78a _PyEval_EvalFrameDefault + 29962
29 com.apple.python3 0x0000000107ad4097 _PyEval_EvalCodeWithName + 3287
30 com.apple.python3 0x00000001079f390d _PyFunction_Vectorcall + 253
31 com.apple.python3 0x0000000107ad3012 call_function + 354
32 com.apple.python3 0x0000000107acf6b9 _PyEval_EvalFrameDefault + 29753
33 com.apple.python3 0x00000001079f378d function_code_fastcall + 237
34 com.apple.python3 0x0000000107ad3012 call_function + 354
35 com.apple.python3 0x0000000107acf6d6 _PyEval_EvalFrameDefault + 29782
36 com.apple.python3 0x00000001079f378d function_code_fastcall + 237
37 com.apple.python3 0x00000001079f3124 PyVectorcall_Call + 100
38 com.apple.python3 0x0000000107acfa34 _PyEval_EvalFrameDefault + 30644
39 com.apple.python3 0x0000000107ad4097 _PyEval_EvalCodeWithName + 3287
40 com.apple.python3 0x00000001079f390d _PyFunction_Vectorcall + 253
41 com.apple.python3 0x00000001079f3124 PyVectorcall_Call + 100
42 com.apple.python3 0x0000000107acfa34 _PyEval_EvalFrameDefault + 30644
43 com.apple.python3 0x00000001079f378d function_code_fastcall + 237
44 com.apple.python3 0x0000000107ad3012 call_function + 354
45 com.apple.python3 0x0000000107acf6b9 _PyEval_EvalFrameDefault + 29753
46 com.apple.python3 0x00000001079f378d function_code_fastcall + 237
47 com.apple.python3 0x0000000107ad3012 call_function + 354
48 com.apple.python3 0x0000000107acf6b9 _PyEval_EvalFrameDefault + 29753
49 com.apple.python3 0x00000001079f378d function_code_fastcall + 237
50 com.apple.python3 0x0000000107ad3012 call_function + 354
51 com.apple.python3 0x0000000107acf6b9 _PyEval_EvalFrameDefault + 29753
52 com.apple.python3 0x00000001079f378d function_code_fastcall + 237
53 com.apple.python3 0x00000001079f2c0a _PyObject_FastCallDict + 218
54 com.apple.python3 0x00000001079f42f3 _PyObject_Call_Prepend + 131
55 com.apple.python3 0x0000000107a4b419 slot_tp_call + 169
56 com.apple.python3 0x00000001079f2dd6 _PyObject_MakeTpCall + 374
57 com.apple.python3 0x0000000107ad313c call_function + 652
58 com.apple.python3 0x0000000107acf6d6 _PyEval_EvalFrameDefault + 29782
59 com.apple.python3 0x00000001079f378d function_code_fastcall + 237
60 com.apple.python3 0x00000001079f2c0a _PyObject_FastCallDict + 218
61 com.apple.python3 0x00000001079f42f3 _PyObject_Call_Prepend + 131
62 com.apple.python3 0x0000000107a4b419 slot_tp_call + 169
63 com.apple.python3 0x00000001079f2dd6 _PyObject_MakeTpCall + 374
64 com.apple.python3 0x0000000107ad313c call_function + 652
65 com.apple.python3 0x0000000107acf6d6 _PyEval_EvalFrameDefault + 29782
66 com.apple.python3 0x0000000107a040b2 gen_send_ex + 242
67 com.apple.python3 0x0000000107acec97 _PyEval_EvalFrameDefault + 27159
68 com.apple.python3 0x0000000107ad4097 _PyEval_EvalCodeWithName + 3287
69 com.apple.python3 0x00000001079f390d _PyFunction_Vectorcall + 253
70 com.apple.python3 0x0000000107ad3012 call_function + 354
71 com.apple.python3 0x0000000107acf78a _PyEval_EvalFrameDefault + 29962
72 com.apple.python3 0x0000000107ad4097 _PyEval_EvalCodeWithName + 3287
73 com.apple.python3 0x00000001079f390d _PyFunction_Vectorcall + 253
74 com.apple.python3 0x0000000107ad3012 call_function + 354
75 com.apple.python3 0x0000000107acf6b9 _PyEval_EvalFrameDefault + 29753
76 com.apple.python3 0x00000001079f378d function_code_fastcall + 237
77 com.apple.python3 0x0000000107ad3012 call_function + 354
78 com.apple.python3 0x0000000107acf6b9 _PyEval_EvalFrameDefault + 29753
79 com.apple.python3 0x00000001079f378d function_code_fastcall + 237
80 com.apple.python3 0x0000000107ad3012 call_function + 354
81 com.apple.python3 0x0000000107acf6d6 _PyEval_EvalFrameDefault + 29782
82 com.apple.python3 0x00000001079f378d function_code_fastcall + 237
83 com.apple.python3 0x0000000107ad3012 call_function + 354
84 com.apple.python3 0x0000000107acf6b9 _PyEval_EvalFrameDefault + 29753
85 com.apple.python3 0x00000001079f378d function_code_fastcall + 237
86 com.apple.python3 0x00000001079f2c0a _PyObject_FastCallDict + 218
87 com.apple.python3 0x00000001079f42f3 _PyObject_Call_Prepend + 131
88 com.apple.python3 0x0000000107a4cb74 slot_tp_init + 180
89 com.apple.python3 0x0000000107a48054 type_call + 292
90 com.apple.python3 0x00000001079f2dd6 _PyObject_MakeTpCall + 374
91 com.apple.python3 0x0000000107ad313c call_function + 652
92 com.apple.python3 0x0000000107acf6d6 _PyEval_EvalFrameDefault + 29782
93 com.apple.python3 0x00000001079f378d function_code_fastcall + 237
94 com.apple.python3 0x0000000107ad3012 call_function + 354
95 com.apple.python3 0x0000000107acf6b9 _PyEval_EvalFrameDefault + 29753
96 com.apple.python3 0x00000001079f378d function_code_fastcall + 237
97 com.apple.python3 0x00000001079f626d method_vectorcall + 461
98 com.apple.python3 0x00000001079f3124 PyVectorcall_Call + 100
99 com.apple.python3 0x0000000107acfa34 _PyEval_EvalFrameDefault + 30644
100 com.apple.python3 0x00000001079f378d function_code_fastcall + 237
101 com.apple.python3 0x0000000107ad3012 call_function + 354
102 com.apple.python3 0x0000000107acf6b9 _PyEval_EvalFrameDefault + 29753
103 com.apple.python3 0x00000001079f378d function_code_fastcall + 237
104 com.apple.python3 0x0000000107ad3012 call_function + 354
105 com.apple.python3 0x0000000107acf6b9 _PyEval_EvalFrameDefault + 29753
106 com.apple.python3 0x00000001079f378d function_code_fastcall + 237
107 com.apple.python3 0x00000001079f61e2 method_vectorcall + 322
108 com.apple.python3 0x00000001079f3124 PyVectorcall_Call + 100
109 com.apple.python3 0x0000000107b7500a t_bootstrap + 74
110 com.apple.python3 0x0000000107b26829 pythread_wrapper + 25
111 libsystem_pthread.dylib 0x00007fff2034e950 _pthread_start + 224
112 libsystem_pthread.dylib 0x00007fff2034a47b thread_start + 15
The relevant part is likely to be hid_enumerate
. After I commented out enumerate class method in hid.py, the crash does not happen again.
Does your Mac use an Intel or M1 CPU?
My MacBook uses Intel Chip
For the record, HID is not used when you communicate with Trezor devices.