Skip to content

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 OSAGetProperty() call.

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.

UPDATE

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.

4 Comments

  1. has has
    I filed a Radar bug with Apple over 10 years ago but the issue appears to have gone unresolved.

    If it’s any consolation, I doubt there’s another person on the planet who could chew through four billion OSAIDs and not even break a sweat. 🙂

  2. 🙂 Actually, I suspect its a 15bit value within AppleScript so I only have 32K OSAIDs to go through.

  3. has has

    O AppleScript, y u short-change us so? :'(

  4. Shane Stanley Shane Stanley

    I think you’re both optimists. It looks more like there’s only 256 to me…

Comments are closed.