OSAID Leaks Cause Crashes
As a followup to my Getting Yosemite AppleScript Progress Information post I would like to offer this PSA.
There an AppleScript crashing bug that you may encounter when using the
If you fail to call
OSADispose() to release the OSAID values you receive from
OSAGetProperty() you have an OSAID leak. If you begin to see difficult to reproduce crashes that look like this then you have an OSAID leak in your application:
#0 0x00007fff97a6a827 in CFRelease () #1 0x00000001054fb6b6 in UASMakeIDTable(unsigned long) () #2 0x00000001054fb81b in UASNewID(TUASScript*) () #3 0x00000001054c0f9d in ASGetPropertyLocal(int, unsigned int, AEDesc const*, unsigned int*) () #4 0x00000001054b7aad in AppleScriptComponent () #5 0x00007fff95704b73 in OSAGetProperty ()
I filed a Radar bug with Apple over 10 years ago but the issue appears to have gone unresolved. It seems to me that when the available OSAIDs have been exhausted,
OSAGetProperty() (and all other OSA calls) should return some sort of error instead of crashing.
If, like me, you wrap your OSAIDs in an Objective-C object, make sure your autorelease pool(s) drain properly. You’re call to
OSADispose() probably happens when your object is dealloced and that may not happen when you expect.