I have an Electron app on macOS Sonoma (arm64 arch). It has a native addon (app.node) using node-addon-api. Recently it crashed, with the stack trace (given below). What is the AXSerializeCFType
function inside the AXUIElementCopyAttributeValue
function, and why did it crash there?
AXUIElementRef systemWideElement = AXUIElementCreateSystemWide();
AXUIElementRef focusedApp = NULL;
AXError error = AXUIElementCopyAttributeValue(systemWideElement, kAXFocusedApplicationAttribute, (CFTypeRef *)&focusedApp);
The crash appears to be occurring in the last line of the code, where I am retrieving the focused app AXUIElementRef
using AXUIElementCopyAttributeValue
. I have already attempted to manually set systemWideElement
to NULL, but AXUIElementCopyAttributeValue
is not crashing; it is just returning an error kAXErrorIllegalArgument
.
OS Version: macOS 14.5 (23F79)
Report Version: 104
Crashed Thread: 344454
Application Specific Information:
Fatal Error: EXC_BAD_ACCESS / KERN_INVALID_ADDRESS / 0x102674000
Thread 344454 Crashed:
0 HIServices 0x18cb5d970 AXSerializeCFType
1 HIServices 0x18cb7ca24 serializeWrapper
2 HIServices 0x18cb7cd40 _AXXMIGCopyAttributeValue
3 HIServices 0x18cb74884 _AXUIElementCopyAttributeValue
4 HIServices 0x18cb74a04 AXUIElementCopyAttributeValue
5 HIServices 0x18cb747fc _AXUIElementCopyAttributeValue
6 HIServices 0x18cb74a04 AXUIElementCopyAttributeValue
7 app.node 0x1027a56f4 getFocusedApplication