Skip to content
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

Mac: crash in ui_element_get_metadata on AXDisclosureTriangle #436

Closed
nriley opened this issue Nov 27, 2021 · 3 comments
Closed

Mac: crash in ui_element_get_metadata on AXDisclosureTriangle #436

nriley opened this issue Nov 27, 2021 · 3 comments

Comments

@nriley
Copy link

nriley commented Nov 27, 2021

Same setup as in #434. This also affects AXSlider and AXHeading.

from talon import Module, actions, ui
from pprint import pprint as pp

mod = Module()

@mod.action_class
class Actions:
	def test():
		"""test"""
		s = ui.apps(bundle='com.apple.controlcenter')[0]
		dm = s.children.find_one(AXRole='AXMenuBarItem', AXIdentifier='com.apple.menuextra.display')
		dm.perform('AXPress')
		actions.sleep(0.1)
		cc = s.children.find_one(AXRole='AXWindow', AXTitle='Control Center')
		dt = cc.children.find_one(AXRole='AXDisclosureTriangle')
		pp(dt)
		pp(dt.attrs) # crashes
		dm.perform('AXPress')
Process:               Talon [15456]
Path:                  /Users/USER/*/Talon.app/Contents/MacOS/Talon
Identifier:            com.talonvoice.Talon
Version:               0.2.0-196-gecaa (109.196)
Code Type:             ARM-64 (Native)
Parent Process:        launchd [1]
User ID:               501

Date/Time:             2021-11-27 13:52:10.5962 -0500
OS Version:            macOS 12.0.1 (21A559)
Report Version:        12
Anonymous UUID:        25EBA5EF-2C5F-63DD-2DE4-E002C97765E5

Sleep/Wake UUID:       87ACA2AF-297B-4DF7-B638-3D4FF793E958

Time Awake Since Boot: 46000 seconds
Time Since Wake:       27576 seconds

System Integrity Protection: enabled

Crashed Thread:        26

Exception Type:        EXC_CRASH (SIGABRT)
Exception Codes:       0x0000000000000000, 0x0000000000000000
Exception Note:        EXC_CORPSE_NOTIFY

Application Specific Information:
*** Terminating app due to uncaught exception 'NSInvalidUnarchiveOperationException', reason: 'This decoder will only decode classes that adopt NSSecureCoding. Class '__NSCFType' does not adopt it.'
abort() called
terminating with uncaught exception of type NSException


Application Specific Backtrace 0:
0   CoreFoundation                      0x00000001939c012c __exceptionPreprocess + 240
1   libobjc.A.dylib                     0x0000000193711808 objc_exception_throw + 60
2   Foundation                          0x0000000194916e0c -[NSCoder __failWithException:] + 180
3   Foundation                          0x00000001948b0d74 -[NSCoder(Exceptions) __failWithExceptionName:errorCode:format:] + 260
4   Foundation                          0x00000001947c5e80 -[NSCoder validateClassSupportsSecureCoding:] + 328
5   Foundation                          0x00000001948020a4 _encodeObject + 420
6   Foundation                          0x00000001948030cc -[NSKeyedArchiver _encodeArrayOfObjects:forKey:] + 380
7   Foundation                          0x0000000194803510 -[NSDictionary(NSDictionary) encodeWithCoder:] + 700
8   Foundation                          0x00000001948023c8 _encodeObject + 1224
9   Foundation                          0x00000001948c41b4 -[NSAttributedString encodeWithCoder:] + 272
10  Talon                               0x0000000102729ad4 ui_element_get_metadata + 3016
11  Talon                               0x0000000102729008 ui_element_get_metadata + 252
12  libffi.dylib                        0x00000001a1934050 ffi_call_SYSV + 80
13  libffi.dylib                        0x00000001a193c9e4 ffi_call_int + 948
14  _cffi_backend.cpython-39-darwin.so  0x000000010a6dcddc PyInit__cffi_backend + 30908
15  libpython3.9.dylib                  0x00000001030d4090 _PyObject_MakeTpCall + 360
16  libpython3.9.dylib                  0x00000001031a7c04 _PyEval_EvalFrameDefault + 33284
17  libpython3.9.dylib                  0x00000001031a551c _PyEval_EvalFrameDefault + 23324
18  libpython3.9.dylib                  0x00000001030d4888 _PyFunction_Vectorcall + 380
19  libpython3.9.dylib                  0x00000001030d6810 PyMethod_New + 352
20  libpython3.9.dylib                  0x00000001031a7ba4 _PyEval_EvalFrameDefault + 33188
21  libpython3.9.dylib                  0x00000001031a551c _PyEval_EvalFrameDefault + 23324
22  libpython3.9.dylib                  0x00000001030d4888 _PyFunction_Vectorcall + 380
23  libpython3.9.dylib                  0x00000001030ddca0 PyWrapper_New + 1208
24  libpython3.9.dylib                  0x000000010311a828 _PyObject_GenericGetAttrWithDict + 196
25  libpython3.9.dylib                  0x0000000103134d8c _PyType_Lookup + 32920
26  libpython3.9.dylib                  0x00000001031a3be4 _PyEval_EvalFrameDefault + 16868
27  libpython3.9.dylib                  0x00000001030d4888 _PyFunction_Vectorcall + 380
28  libpython3.9.dylib                  0x00000001031a5814 _PyEval_EvalFrameDefault + 24084
29  libpython3.9.dylib                  0x00000001031a8af4 _PyEval_EvalFrameDefault + 37108
30  libpython3.9.dylib                  0x00000001030d480c _PyFunction_Vectorcall + 256
31  libpython3.9.dylib                  0x00000001030d6884 PyMethod_New + 468
32  libpython3.9.dylib                  0x00000001031a5814 _PyEval_EvalFrameDefault + 24084
33  libpython3.9.dylib                  0x00000001031a8af4 _PyEval_EvalFrameDefault + 37108
34  libpython3.9.dylib                  0x00000001030d480c _PyFunction_Vectorcall + 256
35  libpython3.9.dylib                  0x00000001030d3eb8 _PyObject_FastCallDictTstate + 272
36  libpython3.9.dylib                  0x00000001030d4b90 _PyObject_Call_Prepend + 148
37  libpython3.9.dylib                  0x0000000103134a4c _PyType_Lookup + 32088
38  libpython3.9.dylib                  0x00000001030d4090 _PyObject_MakeTpCall + 360
39  libpython3.9.dylib                  0x00000001031a7c04 _PyEval_EvalFrameDefault + 33284
40  libpython3.9.dylib                  0x00000001031a551c _PyEval_EvalFrameDefault + 23324
41  libpython3.9.dylib                  0x00000001031a8af4 _PyEval_EvalFrameDefault + 37108
42  libpython3.9.dylib                  0x000000010319f938 PyEval_EvalCode + 80
43  libpython3.9.dylib                  0x000000010319c790 _PyAST_Optimize + 25628
44  libpython3.9.dylib                  0x0000000103115714 PyCMethod_New + 744
45  libpython3.9.dylib                  0x00000001031a7ba4 _PyEval_EvalFrameDefault + 33188
46  libpython3.9.dylib                  0x00000001031a5598 _PyEval_EvalFrameDefault + 23448
47  libpython3.9.dylib                  0x00000001030d4888 _PyFunction_Vectorcall + 380
48  libpython3.9.dylib                  0x00000001031a7ba4 _PyEval_EvalFrameDefault + 33188
49  libpython3.9.dylib                  0x00000001031a54f8 _PyEval_EvalFrameDefault + 23288
50  libpython3.9.dylib                  0x00000001031a8af4 _PyEval_EvalFrameDefault + 37108
51  libpython3.9.dylib                  0x00000001030d480c _PyFunction_Vectorcall + 256
52  libpython3.9.dylib                  0x00000001031a7ba4 _PyEval_EvalFrameDefault + 33188
53  libpython3.9.dylib                  0x00000001031a54f8 _PyEval_EvalFrameDefault + 23288
54  libpython3.9.dylib                  0x00000001030d4888 _PyFunction_Vectorcall + 380
55  libpython3.9.dylib                  0x00000001031a7ba4 _PyEval_EvalFrameDefault + 33188
56  libpython3.9.dylib                  0x00000001031a54f8 _PyEval_EvalFrameDefault + 23288
57  libpython3.9.dylib                  0x00000001030d4888 _PyFunction_Vectorcall + 380
58  libpython3.9.dylib                  0x00000001031a7ba4 _PyEval_EvalFrameDefault + 33188
59  libpython3.9.dylib                  0x00000001031a54f8 _PyEval_EvalFrameDefault + 23288
60  libpython3.9.dylib                  0x00000001030d4888 _PyFunction_Vectorcall + 380
61  libpython3.9.dylib                  0x00000001031a7ba4 _PyEval_EvalFrameDefault + 33188
62  libpython3.9.dylib                  0x00000001031a54f8 _PyEval_EvalFrameDefault + 23288
63  libpython3.9.dylib                  0x00000001030d4888 _PyFunction_Vectorcall + 380
64  libpython3.9.dylib                  0x00000001030d3eb8 _PyObject_FastCallDictTstate + 272
65  libpython3.9.dylib                  0x00000001030d4b90 _PyObject_Call_Prepend + 148
66  libpython3.9.dylib                  0x00000001031364e0 _PyType_Lookup + 38892
67  libpython3.9.dylib                  0x000000010312d584 _PyType_Lookup + 2192
68  libpython3.9.dylib                  0x00000001030d4090 _PyObject_MakeTpCall + 360
69  libpython3.9.dylib                  0x00000001031a7c04 _PyEval_EvalFrameDefault + 33284
70  libpython3.9.dylib                  0x00000001031a551c _PyEval_EvalFrameDefault + 23324
71  libpython3.9.dylib                  0x00000001030d4888 _PyFunction_Vectorcall + 380
72  libpython3.9.dylib                  0x00000001031a7ba4 _PyEval_EvalFrameDefault + 33188
73  libpython3.9.dylib                  0x00000001031a54f8 _PyEval_EvalFrameDefault + 23288
74  libpython3.9.dylib                  0x00000001030d4888 _PyFunction_Vectorcall + 380
75  libpython3.9.dylib                  0x00000001030d68f4 PyMethod_New + 580
76  libpython3.9.dylib                  0x00000001031a5814 _PyEval_EvalFrameDefault + 24084
77  libpython3.9.dylib                  0x00000001030d4888 _PyFunction_Vectorcall + 380
78  libpython3.9.dylib                  0x00000001031a7ba4 _PyEval_EvalFrameDefault + 33188
79  libpython3.9.dylib                  0x00000001031a54f8 _PyEval_EvalFrameDefault + 23288
80  libpython3.9.dylib                  0x00000001030d4888 _PyFunction_Vectorcall + 380
81  libpython3.9.dylib                  0x00000001031a7ba4 _PyEval_EvalFrameDefault + 33188
82  libpython3.9.dylib                  0x00000001031a54f8 _PyEval_EvalFrameDefault + 23288
83  libpython3.9.dylib                  0x00000001030d4888 _PyFunction_Vectorcall + 380
84  libpython3.9.dylib                  0x00000001030d6884 PyMethod_New + 468
85  libpython3.9.dylib                  0x0000000103241a50 PyInit__thread + 6468
86  libpython3.9.dylib                  0x00000001031f2de0 PyThread_start_new_thread + 320
87  libsystem_pthread.dylib             0x00000001938754ec _pthread_start + 148
88  libsystem_pthread.dylib             0x00000001938702d0 thread_start + 8
@lunixbochs
Copy link

We're crashing on this:

AXAttributedDescription Forward{
    AXATextAlignmentValue = 0;
    AXFont =     {
        AXFontFamily = ".AppleSystemUIFont";
        AXFontName = ".SFNS-Regular";
        AXFontSize = 13;
        AXVisibleName = "System Font Regular";
    };
    AXForegroundColor = "<CGColor 0x600002340180> [<CGColorSpace 0x6000023055c0> (kCGColorSpaceICCBased; kCGColorSpaceModelRGB; Generic RGB Profile)] ( 1 1 1 0.898039 )";
    AXLanguage = "en-US";
}

My guess is that the CGColor in AXForegroundColor is the issue. NSAttributedString is very annoying to serialize manually, so I was using NSPropertyListXMLFormat_v1_0 with a [[NSKeyedArchiver alloc] initRequiringSecureCoding:YES]. I'll allow that to fail more gracefully.

@lunixbochs
Copy link

fixed in beta 0.2.0-201

@nriley
Copy link
Author

nriley commented Nov 28, 2021

Works, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants