trustcrypto/onlykey-agent

onlykey-agent crashes on mac

cizmazia opened this issue · 15 comments

When I run git pull with onlykey-agent, it works as expected except that macOS always opens a modal window "Python quit unexpectedly" with the crash report below.

Command:

$ onlykey-agent git@github.com -- git pull
Enter the 3 digit challenge code on OnlyKey to authorize <ssh://git@github.com|ed25519>
6 3 5
Already up to date.
[1]    26326 trace trap  onlykey-agent git@github.com -- git pull

$ onlykey-agent --version
onlykey-agent=1.1.14 lib-agent=1.0.5
Crash Report (click to expand)
-------------------------------------
Translated Report (Full Report Below)
-------------------------------------

Process:               Python [28562]
Path:                  /Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/Resources/Python.app/Contents/MacOS/Python
Identifier:            com.apple.python3
Version:               3.9.6 (3.9.6)
Build Info:            python3-124000000000000~2105
Code Type:             ARM-64 (Native)
Parent Process:        zsh [20509]
Responsible:           Terminal [1184]
User ID:               501

Date/Time:             2022-12-10 16:44:42.7602 +0100
OS Version:            macOS 13.0.1 (22A400)
Report Version:        12
Anonymous UUID:        6EC8A772-3004-3369-A691-867F7FD6E93F

Sleep/Wake UUID:       3A7AF147-1A15-4107-987B-A584FA041AAD

Time Awake Since Boot: 590000 seconds
Time Since Wake:       3774 seconds

System Integrity Protection: enabled

Crashed Thread:        0  Dispatch queue: com.apple.main-thread

Exception Type:        EXC_BREAKPOINT (SIGTRAP)
Exception Codes:       0x0000000000000001, 0x00000001a95d7e74

Termination Reason:    Namespace SIGNAL, Code 5 Trace/BPT trap: 5
Terminating Process:   exc handler [28562]

Thread 0 Crashed::  Dispatch queue: com.apple.main-thread
0   CoreFoundation                	       0x1a95d7e74 _CFAssertMismatchedTypeID + 112
1   CoreFoundation                	       0x1a95d7e6c _CFAssertMismatchedTypeID + 104
2   CoreFoundation                	       0x1a9497ccc CFRunLoopRemoveSource + 704
3   IOKit                         	       0x1ac59aa30 IOHIDDeviceUnscheduleFromRunLoop + 140
4   IOKit                         	       0x1ac59f8fc __IOHIDManagerDeviceApplier + 660
5   CoreFoundation                	       0x1a943f1d4 __CFSetApplyFunction_block_invoke + 28
6   CoreFoundation                	       0x1a943efec CFBasicHashApply + 148
7   CoreFoundation                	       0x1a943ef30 CFSetApplyFunction + 320
8   IOKit                         	       0x1ac59dfd4 __ApplyToDevices + 128
9   IOKit                         	       0x1ac59e110 IOHIDManagerUnscheduleFromRunLoop + 112
10  IOKit                         	       0x1ac59e034 IOHIDManagerClose + 44
11  hid.cpython-39-darwin.so      	       0x10557426c hid_exit + 32
12  hid.cpython-39-darwin.so      	       0x105574114 __pyx_pw_11cfunc_dot_to_py_27__Pyx_CFunc_int_______to_py_1wrap + 24
13  Python3                       	       0x1048c44b8 _PyObject_Call + 172
14  Python3                       	       0x1049a304c _PyEval_EvalFrameDefault + 24592
15  Python3                       	       0x1049a63d4 0x104884000 + 1188820
16  Python3                       	       0x1048c4678 _PyFunction_Vectorcall + 236
17  Python3                       	       0x1048c3d10 _PyObject_FastCallDictTstate + 272
18  Python3                       	       0x1048c4a58 _PyObject_Call_Prepend + 148
19  Python3                       	       0x104929e4c 0x104884000 + 679500
20  Python3                       	       0x1048c3ee8 _PyObject_MakeTpCall + 360
21  Python3                       	       0x1049a56d0 0x104884000 + 1185488
22  Python3                       	       0x1049a2dd4 _PyEval_EvalFrameDefault + 23960
23  Python3                       	       0x1048c4730 0x104884000 + 263984
24  Python3                       	       0x1048c689c 0x104884000 + 272540
25  Python3                       	       0x104a3d88c 0x104884000 + 1808524
26  Python3                       	       0x1049dfda8 Py_FinalizeEx + 72
27  Python3                       	       0x1049e0a80 Py_Exit + 20
28  Python3                       	       0x1049e5cc8 0x104884000 + 1449160
29  Python3                       	       0x1049e4b48 PyRun_SimpleFileExFlags + 912
30  Python3                       	       0x104a02df0 Py_RunMain + 1640
31  Python3                       	       0x104a03280 0x104884000 + 1569408
32  Python3                       	       0x104a03320 Py_BytesMain + 40
33  dyld                          	       0x1a906be50 start + 2544

I also experience this issue and have been ignoring it for a while. I will investigate, and would love it if someone has a hunch of where to look.

For reference, here is what I see in my own "Crash Report" from the Console app:

Translated Report (Full Report Below)
-------------------------------------
Translated Report (Full Report Below)
-------------------------------------

Process:               Python [42239]
Path:                  /usr/local/Cellar/python@3.10/3.10.9/Frameworks/Python.framework/Versions/3.10/Resources/Python.app/Contents/MacOS/Python
Identifier:            org.python.python
Version:               3.10.9 (3.10.9)
Code Type:             X86-64 (Native)
Parent Process:        zsh [42166]
Responsible:           Terminal [42164]
User ID:               501

Date/Time:             2023-01-15 13:36:30.6058 -0800
OS Version:            macOS 13.1 (22C65)
Report Version:        12
Anonymous UUID:        65B2B8D4-24C2-AF4F-885A-4B58BAD42209

Sleep/Wake UUID:       6CB6B3FD-73BA-489B-9A0B-D517BABF6F43

Time Awake Since Boot: 35000 seconds
Time Since Wake:       885 seconds

System Integrity Protection: enabled

Crashed Thread:        0  Dispatch queue: com.apple.main-thread

Exception Type:        EXC_BAD_INSTRUCTION (SIGILL)
Exception Codes:       0x0000000000000001, 0x0000000000000000

Termination Reason:    Namespace SIGNAL, Code 4 Illegal instruction: 4
Terminating Process:   exc handler [42239]

Thread 0 Crashed::  Dispatch queue: com.apple.main-thread
0   CoreFoundation                	    0x7ff81c10df6e _CFAssertMismatchedTypeID + 110
1   CoreFoundation                	    0x7ff81bfdf5ba CFRunLoopRemoveSource + 670
2   IOKit                         	    0x7ff81efec995 IOHIDDeviceUnscheduleFromRunLoop + 147
3   IOKit                         	    0x7ff81eff106a __IOHIDManagerDeviceApplier + 584
4   CoreFoundation                	    0x7ff81bf8ad36 __CFSetApplyFunction_block_invoke + 18
5   CoreFoundation                	    0x7ff81bf8ab94 CFBasicHashApply + 124
6   CoreFoundation                	    0x7ff81bf8aada CFSetApplyFunction + 131
7   IOKit                         	    0x7ff81efef992 __ApplyToDevices + 107
8   IOKit                         	    0x7ff81efefa9b IOHIDManagerUnscheduleFromRunLoop + 92
9   IOKit                         	    0x7ff81efef9e4 IOHIDManagerClose + 34
10  libhidapi.0.12.0.dylib        	       0x108346a5d hid_exit + 23
11  hid.cpython-310-darwin.so     	       0x1083689f3 __pyx_pw_11cfunc_dot_to_py_27__Pyx_CFunc_int_______to_py_1wrap + 13
12  Python                        	       0x10740025d _PyObject_Call + 121
13  Python                        	       0x1074ebff8 _PyEval_EvalFrameDefault + 3185
14  Python                        	       0x1074ea0bb _PyEval_Vector + 342
15  Python                        	       0x1073ff967 _PyObject_FastCallDictTstate + 87
16  Python                        	       0x10746f34c slot_tp_call + 196
17  Python                        	       0x1073ff743 _PyObject_MakeTpCall + 132
18  Python                        	       0x1074fa1d3 call_function + 292
19  Python                        	       0x1074f017b _PyEval_EvalFrameDefault + 19956
20  Python                        	       0x1074ea0bb _PyEval_Vector + 342
21  Python                        	       0x107402d1b method_vectorcall + 481
22  Python                        	       0x1075b0684 atexit_callfuncs + 97
23  Python                        	       0x107543340 Py_FinalizeEx + 74
24  Python                        	       0x1075454b7 Py_Exit + 13
25  Python                        	       0x107549a5e handle_system_exit + 35
26  Python                        	       0x107548187 _PyErr_PrintEx + 42
27  Python                        	       0x107548b8d _PyRun_SimpleFileObject + 487
28  Python                        	       0x107548134 _PyRun_AnyFileObject + 155
29  Python                        	       0x10756a060 pymain_run_file_obj + 234
30  Python                        	       0x10756981f pymain_run_file + 85
31  Python                        	       0x1075691d5 Py_RunMain + 987
32  Python                        	       0x10756a484 Py_BytesMain + 42
33  dyld                          	    0x7ff81bbb0310 start + 2432

Thread 1:
0   libsystem_pthread.dylib       	    0x7ff81bedec58 start_wqthread + 0

Thread 2:
0   libsystem_pthread.dylib       	    0x7ff81bedec58 start_wqthread + 0


Thread 0 crashed with X86 Thread State (64-bit):
  rax: 0x000000000000004a  rbx: 0x00007ff81c29a4e0  rcx: 0x3e8be2a021a400d4  rdx: 0x0000000000000000
  rdi: 0x0000000000000000  rsi: 0x00007ff81c29b514  rbp: 0x00007ff7b8f597a0  rsp: 0x00007ff7b8f59670
   r8: 0x00007ff7b8f593d0   r9: 0x00007ff81c29b515  r10: 0x0000000000000000  r11: 0xffffffff9ccbe1b5
  r12: 0x00007ff7b8f59680  r13: 0x00006000013146c0  r14: 0x0000000000000000  r15: 0x000000000000002b
  rip: 0x00007ff81c10df6e  rfl: 0x0000000000010206  cr2: 0x0000000107a5b630
  
Logical CPU:     0
Error Code:      0x00000000 
Trap Number:     6

Thread 0 instruction stream:
  10 01 00 00 49 89 f6 49-89 ff e8 3b d3 f7 ff 48  ....I..I...;...H
  89 c3 48 85 c0 4c 8d 25-9c be 18 00 49 0f 44 dc  ..H..L.%....I.D.
  4c 89 f7 e8 22 d3 f7 ff-48 85 c0 49 0f 44 c4 48  L..."...H..I.D.H
  89 04 24 48 8d 15 8f d5-18 00 4c 8d a5 e0 fe ff  ..$H......L.....
  ff be ff 00 00 00 4c 89-e7 4c 89 f9 49 89 d8 4d  ......L..L..I..M
  89 f1 31 c0 e8 45 aa 00-00 4c 89 25 ca a8 b3 41  ..1..E...L.%...A
 [0f]0b 48 8d 05 19 d4 18-00 48 89 05 ba a8 b3 41  ..H......H.....A	<==
  0f 0b 48 8d 05 44 d4 18-00 48 89 05 aa a8 b3 41  ..H..D...H.....A
  0f 0b 48 8d 05 7f d5 18-00 48 89 05 9a a8 b3 41  ..H......H.....A
  0f 0b 48 8d 05 9a d7 18-00 48 89 05 8a a8 b3 41  ..H......H.....A
  0f 0b 48 8d 05 8a d7 18-00 48 89 05 7a a8 b3 41  ..H......H..z..A
  0f 0b 48 8d 05 7a d7 18-00 48 89 05 6a a8 b3 41  ..H..z...H..j..A

Binary Images:
    0x7ff81bf3f000 -     0x7ff81c3d8fff com.apple.CoreFoundation (6.9) <beb5fc0b-7196-3c1d-a59a-f62ada98f592> /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation
    0x7ff81efad000 -     0x7ff81f06bff8 com.apple.framework.IOKit (2.0.2) <07d95c28-6bd6-3088-b2ac-019581c88565> /System/Library/Frameworks/IOKit.framework/Versions/A/IOKit
       0x108344000 -        0x108347fff libhidapi.0.12.0.dylib (*) <2f426dac-eab8-363a-8c0d-b77df7fb673c> /usr/local/Cellar/hidapi/0.12.0/lib/libhidapi.0.12.0.dylib
       0x10835e000 -        0x108369fff hid.cpython-310-darwin.so (*) <751ab224-1282-3064-b0c7-d15066f1fd5b> /usr/local/Cellar/onlykey-agent/1.1.14_1/libexec/lib/python3.10/site-packages/hid.cpython-310-darwin.so
       0x107395000 -        0x107668fff org.python.python (3.10.9, (c) 2001-2021 Python Software Foundation.) <7aafcb95-0043-3321-afdf-255c95be2bcc> /usr/local/Cellar/python@3.10/3.10.9/Frameworks/Python.framework/Versions/3.10/Python
    0x7ff81bbaa000 -     0x7ff81bc3ec6f dyld (*) <bb7a0970-8c62-3dce-a7a2-5cec9c501f11> /usr/lib/dyld
    0x7ff81bedd000 -     0x7ff81bee8ff7 libsystem_pthread.dylib (*) <5920e36f-53ec-33f0-b675-8ae48b58418c> /usr/lib/system/libsystem_pthread.dylib

External Modification Summary:
  Calls made by other processes targeting this process:
    task_for_pid: 0
    thread_create: 0
    thread_set_state: 0
  Calls made by this process:
    task_for_pid: 0
    thread_create: 0
    thread_set_state: 0
  Calls made by all processes on this machine:
    task_for_pid: 0
    thread_create: 0
    thread_set_state: 0

VM Region Summary:
ReadOnly portion of Libraries: Total=397.0M resident=0K(0%) swapped_out_or_unallocated=397.0M(100%)
Writable regions: Total=1.2G written=0K(0%) resident=0K(0%) swapped_out=0K(0%) unallocated=1.2G(100%)

                                VIRTUAL   REGION 
REGION TYPE                        SIZE    COUNT (non-coalesced) 
===========                     =======  ======= 
Activity Tracing                   256K        1 
Kernel Alloc Once                    8K        1 
MALLOC                           213.1M       24 
MALLOC guard page                   24K        5 
MALLOC_MEDIUM (reserved)         600.0M        5         reserved VM address space (unallocated)
MALLOC_NANO (reserved)           384.0M        1         reserved VM address space (unallocated)
STACK GUARD                         12K        3 
Stack                             17.0M        3 
VM_ALLOCATE                       15.0M       16 
__DATA                            15.0M      303 
__DATA_CONST                      13.9M      205 
__DATA_DIRTY                       623K       96 
__FONT_DATA                        2352        1 
__LINKEDIT                       183.4M       41 
__OBJC_RO                         65.4M        1 
__OBJC_RW                         1988K        2 
__TEXT                           213.6M      324 
dyld private memory                256K        1 
mapped file                        184K        2 
shared memory                       20K        3 
===========                     =======  ======= 
TOTAL                              1.7G     1038 
TOTAL, minus reserved VM space   739.8M     1038 



-----------
Full Report
-----------

{"app_name":"Python","timestamp":"2023-01-15 13:36:30.00 -0800","app_version":"3.10.9","slice_uuid":"ca47a6f0-565a-3861-ad9d-ebd4151834aa","build_version":"3.10.9","platform":1,"bundleID":"org.python.python","share_with_app_devs":1,"is_first_party":0,"bug_type":"309","os_version":"macOS 13.1 (22C65)","roots_installed":0,"name":"Python","incident_id":"3061EFCB-868E-4222-BDE6-9CE583532C35"}
{
  "uptime" : 35000,
  "procRole" : "Unspecified",
  "version" : 2,
  "userID" : 501,
  "deployVersion" : 210,
  "modelCode" : "iMac18,3",
  "coalitionID" : 5907,
  "osVersion" : {
    "train" : "macOS 13.1",
    "build" : "22C65",
    "releaseType" : "User"
  },
  "captureTime" : "2023-01-15 13:36:30.6058 -0800",
  "incident" : "3061EFCB-868E-4222-BDE6-9CE583532C35",
  "pid" : 42239,
  "cpuType" : "X86-64",
  "roots_installed" : 0,
  "bug_type" : "309",
  "procLaunch" : "2023-01-15 13:36:27.2211 -0800",
  "procStartAbsTime" : 35710155726975,
  "procExitAbsTime" : 35713540199032,
  "procName" : "Python",
  "procPath" : "\/usr\/local\/Cellar\/python@3.10\/3.10.9\/Frameworks\/Python.framework\/Versions\/3.10\/Resources\/Python.app\/Contents\/MacOS\/Python",
  "bundleInfo" : {"CFBundleShortVersionString":"3.10.9","CFBundleVersion":"3.10.9","CFBundleIdentifier":"org.python.python"},
  "storeInfo" : {"deviceIdentifierForVendor":"DAFF5618-B553-5BC6-A445-178BD1E796FD","thirdParty":true},
  "parentProc" : "zsh",
  "parentPid" : 42166,
  "coalitionName" : "com.apple.Terminal",
  "crashReporterKey" : "65B2B8D4-24C2-AF4F-885A-4B58BAD42209",
  "responsiblePid" : 42164,
  "responsibleProc" : "Terminal",
  "wakeTime" : 885,
  "sleepWakeUUID" : "6CB6B3FD-73BA-489B-9A0B-D517BABF6F43",
  "sip" : "enabled",
  "exception" : {"codes":"0x0000000000000001, 0x0000000000000000","rawCodes":[1,0],"type":"EXC_BAD_INSTRUCTION","signal":"SIGILL"},
  "termination" : {"flags":0,"code":4,"namespace":"SIGNAL","indicator":"Illegal instruction: 4","byProc":"exc handler","byPid":42239},
  "extMods" : {"caller":{"thread_create":0,"thread_set_state":0,"task_for_pid":0},"system":{"thread_create":0,"thread_set_state":0,"task_for_pid":0},"targeted":{"thread_create":0,"thread_set_state":0,"task_for_pid":0},"warnings":0},
  "faultingThread" : 0,
  "threads" : [{"triggered":true,"id":495189,"instructionState":{"instructionStream":{"bytes":[16,1,0,0,73,137,246,73,137,255,232,59,211,247,255,72,137,195,72,133,192,76,141,37,156,190,24,0,73,15,68,220,76,137,247,232,34,211,247,255,72,133,192,73,15,68,196,72,137,4,36,72,141,21,143,213,24,0,76,141,165,224,254,255,255,190,255,0,0,0,76,137,231,76,137,249,73,137,216,77,137,241,49,192,232,69,170,0,0,76,137,37,202,168,179,65,15,11,72,141,5,25,212,24,0,72,137,5,186,168,179,65,15,11,72,141,5,68,212,24,0,72,137,5,170,168,179,65,15,11,72,141,5,127,213,24,0,72,137,5,154,168,179,65,15,11,72,141,5,154,215,24,0,72,137,5,138,168,179,65,15,11,72,141,5,138,215,24,0,72,137,5,122,168,179,65,15,11,72,141,5,122,215,24,0,72,137,5,106,168,179,65],"offset":96}},"threadState":{"r13":{"value":105553136273088},"rax":{"value":74},"rflags":{"value":66054},"cpu":{"value":0},"r14":{"value":0},"rsi":{"value":140703601112340,"symbolLocation":7412,"symbol":"_XMLPlistAppendDataUsingBase64.__CFPLDataEncodeTable"},"r8":{"value":140701936751568},"cr2":{"value":4423267888},"rdx":{"value":0},"r10":{"value":0},"r9":{"value":140703601112341,"symbolLocation":7413,"symbol":"_XMLPlistAppendDataUsingBase64.__CFPLDataEncodeTable"},"r15":{"value":43},"rbx":{"value":140703601108192,"symbolLocation":3264,"symbol":"_XMLPlistAppendDataUsingBase64.__CFPLDataEncodeTable"},"trap":{"value":6},"err":{"value":0},"r11":{"value":18446744072045191605},"rip":{"value":140703599484782,"matchesCrashFrame":1},"rbp":{"value":140701936752544},"rsp":{"value":140701936752240},"r12":{"value":140701936752256},"rcx":{"value":4506945029501354196},"flavor":"x86_THREAD_STATE","rdi":{"value":0}},"queue":"com.apple.main-thread","frames":[{"imageOffset":1896302,"symbol":"_CFAssertMismatchedTypeID","symbolLocation":110,"imageIndex":0},{"imageOffset":656826,"symbol":"CFRunLoopRemoveSource","symbolLocation":670,"imageIndex":0},{"imageOffset":260501,"symbol":"IOHIDDeviceUnscheduleFromRunLoop","symbolLocation":147,"imageIndex":1},{"imageOffset":278634,"symbol":"__IOHIDManagerDeviceApplier","symbolLocation":584,"imageIndex":1},{"imageOffset":310582,"symbol":"__CFSetApplyFunction_block_invoke","symbolLocation":18,"imageIndex":0},{"imageOffset":310164,"symbol":"CFBasicHashApply","symbolLocation":124,"imageIndex":0},{"imageOffset":309978,"symbol":"CFSetApplyFunction","symbolLocation":131,"imageIndex":0},{"imageOffset":272786,"symbol":"__ApplyToDevices","symbolLocation":107,"imageIndex":1},{"imageOffset":273051,"symbol":"IOHIDManagerUnscheduleFromRunLoop","symbolLocation":92,"imageIndex":1},{"imageOffset":272868,"symbol":"IOHIDManagerClose","symbolLocation":34,"imageIndex":1},{"imageOffset":10845,"symbol":"hid_exit","symbolLocation":23,"imageIndex":2},{"imageOffset":43507,"symbol":"__pyx_pw_11cfunc_dot_to_py_27__Pyx_CFunc_int_______to_py_1wrap","symbolLocation":13,"imageIndex":3},{"imageOffset":438877,"symbol":"_PyObject_Call","symbolLocation":121,"imageIndex":4},{"imageOffset":1404920,"symbol":"_PyEval_EvalFrameDefault","symbolLocation":3185,"imageIndex":4},{"imageOffset":1396923,"symbol":"_PyEval_Vector","symbolLocation":342,"imageIndex":4},{"imageOffset":436583,"symbol":"_PyObject_FastCallDictTstate","symbolLocation":87,"imageIndex":4},{"imageOffset":893772,"symbol":"slot_tp_call","symbolLocation":196,"imageIndex":4},{"imageOffset":436035,"symbol":"_PyObject_MakeTpCall","symbolLocation":132,"imageIndex":4},{"imageOffset":1462739,"symbol":"call_function","symbolLocation":292,"imageIndex":4},{"imageOffset":1421691,"symbol":"_PyEval_EvalFrameDefault","symbolLocation":19956,"imageIndex":4},{"imageOffset":1396923,"symbol":"_PyEval_Vector","symbolLocation":342,"imageIndex":4},{"imageOffset":449819,"symbol":"method_vectorcall","symbolLocation":481,"imageIndex":4},{"imageOffset":2209412,"symbol":"atexit_callfuncs","symbolLocation":97,"imageIndex":4},{"imageOffset":1762112,"symbol":"Py_FinalizeEx","symbolLocation":74,"imageIndex":4},{"imageOffset":1770679,"symbol":"Py_Exit","symbolLocation":13,"imageIndex":4},{"imageOffset":1788510,"symbol":"handle_system_exit","symbolLocation":35,"imageIndex":4},{"imageOffset":1782151,"symbol":"_PyErr_PrintEx","symbolLocation":42,"imageIndex":4},{"imageOffset":1784717,"symbol":"_PyRun_SimpleFileObject","symbolLocation":487,"imageIndex":4},{"imageOffset":1782068,"symbol":"_PyRun_AnyFileObject","symbolLocation":155,"imageIndex":4},{"imageOffset":1921120,"symbol":"pymain_run_file_obj","symbolLocation":234,"imageIndex":4},{"imageOffset":1919007,"symbol":"pymain_run_file","symbolLocation":85,"imageIndex":4},{"imageOffset":1917397,"symbol":"Py_RunMain","symbolLocation":987,"imageIndex":4},{"imageOffset":1922180,"symbol":"Py_BytesMain","symbolLocation":42,"imageIndex":4},{"imageOffset":25360,"symbol":"start","symbolLocation":2432,"imageIndex":5}]},{"id":495212,"frames":[{"imageOffset":7256,"symbol":"start_wqthread","symbolLocation":0,"imageIndex":6}]},{"id":495213,"frames":[{"imageOffset":7256,"symbol":"start_wqthread","symbolLocation":0,"imageIndex":6}]}],
  "usedImages" : [
  {
    "source" : "P",
    "arch" : "x86_64h",
    "base" : 140703597588480,
    "CFBundleShortVersionString" : "6.9",
    "CFBundleIdentifier" : "com.apple.CoreFoundation",
    "size" : 4825088,
    "uuid" : "beb5fc0b-7196-3c1d-a59a-f62ada98f592",
    "path" : "\/System\/Library\/Frameworks\/CoreFoundation.framework\/Versions\/A\/CoreFoundation",
    "name" : "CoreFoundation",
    "CFBundleVersion" : "1953.300"
  },
  {
    "source" : "P",
    "arch" : "x86_64",
    "base" : 140703648370688,
    "CFBundleShortVersionString" : "2.0.2",
    "CFBundleIdentifier" : "com.apple.framework.IOKit",
    "size" : 782329,
    "uuid" : "07d95c28-6bd6-3088-b2ac-019581c88565",
    "path" : "\/System\/Library\/Frameworks\/IOKit.framework\/Versions\/A\/IOKit",
    "name" : "IOKit"
  },
  {
    "source" : "P",
    "arch" : "x86_64",
    "base" : 4432609280,
    "size" : 16384,
    "uuid" : "2f426dac-eab8-363a-8c0d-b77df7fb673c",
    "path" : "\/usr\/local\/Cellar\/hidapi\/0.12.0\/lib\/libhidapi.0.12.0.dylib",
    "name" : "libhidapi.0.12.0.dylib"
  },
  {
    "source" : "P",
    "arch" : "x86_64",
    "base" : 4432715776,
    "size" : 49152,
    "uuid" : "751ab224-1282-3064-b0c7-d15066f1fd5b",
    "path" : "\/usr\/local\/Cellar\/onlykey-agent\/1.1.14_1\/libexec\/lib\/python3.10\/site-packages\/hid.cpython-310-darwin.so",
    "name" : "hid.cpython-310-darwin.so"
  },
  {
    "source" : "P",
    "arch" : "x86_64",
    "base" : 4416163840,
    "CFBundleShortVersionString" : "3.10.9, (c) 2001-2021 Python Software Foundation.",
    "CFBundleIdentifier" : "org.python.python",
    "size" : 2965504,
    "uuid" : "7aafcb95-0043-3321-afdf-255c95be2bcc",
    "path" : "\/usr\/local\/Cellar\/python@3.10\/3.10.9\/Frameworks\/Python.framework\/Versions\/3.10\/Python",
    "name" : "Python",
    "CFBundleVersion" : "3.10.9"
  },
  {
    "source" : "P",
    "arch" : "x86_64",
    "base" : 140703593832448,
    "size" : 609392,
    "uuid" : "bb7a0970-8c62-3dce-a7a2-5cec9c501f11",
    "path" : "\/usr\/lib\/dyld",
    "name" : "dyld"
  },
  {
    "source" : "P",
    "arch" : "x86_64",
    "base" : 140703597187072,
    "size" : 49144,
    "uuid" : "5920e36f-53ec-33f0-b675-8ae48b58418c",
    "path" : "\/usr\/lib\/system\/libsystem_pthread.dylib",
    "name" : "libsystem_pthread.dylib"
  }
],
  "sharedCache" : {
  "base" : 140703593226240,
  "size" : 21474836480,
  "uuid" : "ea7f9772-219e-3ece-a4d9-20aeee3bc80f"
},
  "vmSummary" : "ReadOnly portion of Libraries: Total=397.0M resident=0K(0%) swapped_out_or_unallocated=397.0M(100%)\nWritable regions: Total=1.2G written=0K(0%) resident=0K(0%) swapped_out=0K(0%) unallocated=1.2G(100%)\n\n                                VIRTUAL   REGION \nREGION TYPE                        SIZE    COUNT (non-coalesced) \n===========                     =======  ======= \nActivity Tracing                   256K        1 \nKernel Alloc Once                    8K        1 \nMALLOC                           213.1M       24 \nMALLOC guard page                   24K        5 \nMALLOC_MEDIUM (reserved)         600.0M        5         reserved VM address space (unallocated)\nMALLOC_NANO (reserved)           384.0M        1         reserved VM address space (unallocated)\nSTACK GUARD                         12K        3 \nStack                             17.0M        3 \nVM_ALLOCATE                       15.0M       16 \n__DATA                            15.0M      303 \n__DATA_CONST                      13.9M      205 \n__DATA_DIRTY                       623K       96 \n__FONT_DATA                        2352        1 \n__LINKEDIT                       183.4M       41 \n__OBJC_RO                         65.4M        1 \n__OBJC_RW                         1988K        2 \n__TEXT                           213.6M      324 \ndyld private memory                256K        1 \nmapped file                        184K        2 \nshared memory                       20K        3 \n===========                     =======  ======= \nTOTAL                              1.7G     1038 \nTOTAL, minus reserved VM space   739.8M     1038 \n",
  "legacyInfo" : {
  "threadTriggered" : {
    "queue" : "com.apple.main-thread"
  }
},
  "trialInfo" : {
  "rollouts" : [
    {
      "rolloutId" : "61fd92db295c182621ececc3",
      "factorPackIds" : {

      },
      "deploymentId" : 240000262
    },
    {
      "rolloutId" : "63582c5f8a53461413999550",
      "factorPackIds" : {

      },
      "deploymentId" : 240000002
    }
  ],
  "experiments" : [

  ]
}
}


I looked at this for a bit tonight and I don't see an obvious solution. It seems benign, but in case this might help someone else fix it (or point me in the right direction to fix it):

Based on the call stack that I experience (I posted above) the error happens after successful usage of onlykey, and it appears to be called from the finalizer in cython-hidapi at https://github.com/trezor/cython-hidapi/blob/master/hid.pyx#L418

NOTE: More on weakref.finalize: https://docs.python.org/3/library/weakref.html#weakref.finalize

The finalizer calls in the underlying hidapi lib's hid_exit at 
https://github.com/libusb/hidapi/blob/master/mac/hid.c#L451 . hid_exit is calling the IOKit API IOHIDManagerClose.

NOTE: IOHIDManagerClose is described at https://developer.apple.com/documentation/iokit/1438405-iohidmanagerclose

@activescott thanks for taking a look! Do you have any workaround to prevent macos from opening the crash report modal window?

Might be an issue with cython-hidapi I am open to ideas to try here. I might be able to try a delay before closing and see if that affects this https://github.com/onlykey/lib-agent/blob/da6461a6eb4b97fc306f975019c8a83ef47c90a5/libagent/device/onlykey.py#L137

@cizmazia I'm sorry I don't. I'd like to see this fixed at the source rather than hide it so I'm going to let it annoy me in hopes it will provoke me enough to dig in again sometime 🙃

@onlykey I also suspect cython-hidap I'm also open to ideas - since I couldn't put my finger on the root cause here. I will hack my local instance of libagent there and see if it gets rid of the issue for me. I'll post back with what I see

still seeing the crash when adding a time.sleep(0.1) or time.sleep(1) locally. Let me know if anyone else has other ideas to try though

Similar issue here, the partial solution mentioned is to use docker - https://onlykey.discourse.group/t/onlykey-agent-macos-illegal-instruction/833/9

@cizmazia Thanks, yes it looks like its a problem with hidapi on certain Mac versions. @activescott Can you verify that using hidapi 0.10.1 fixes this issue for you?

pip install hidapi==0.10.1 fixed the issue

Yep that fixes it for me! 🥳

I normally use homebrew-installed version so I switched to pip momentarily to verify this. I'm not exactly sure how to update the homebrew formula to pin an old version of hidapi but I'll try to find time to look into it and see if its an easy fix.

This seems to be fixed in cython-hidapi 0.14.0 but I still experience the issue with hidapi 0.14.0 and I am no longer able to downgrade back to the latest working version of hidapi 0.10.1.