{"id":893,"date":"2014-12-04T09:59:16","date_gmt":"2014-12-04T16:59:16","guid":{"rendered":"http:\/\/blog.latenightsw.com\/?p=893"},"modified":"2014-12-04T12:14:51","modified_gmt":"2014-12-04T19:14:51","slug":"osaid-leaks-cause-crashes","status":"publish","type":"post","link":"http:\/\/markalldritt.com\/?p=893","title":{"rendered":"OSAID Leaks Cause Crashes"},"content":{"rendered":"<p>As a followup to my <a href=\"http:\/\/blog.latenightsw.com\/?p=836\">Getting Yosemite AppleScript Progress Information<\/a> post I would like to offer this PSA.<\/p>\n\n<p>There an AppleScript crashing bug that you may encounter when using the <code>OSAGetProperty()<\/code> call.<\/p>\n\n<p>If you fail to call <code>OSADispose()<\/code> to release the OSAID values you receive from <code>OSAGetProperty()<\/code> 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: <\/p>\n\n<pre><code>#0  0x00007fff97a6a827 in CFRelease ()\n#1  0x00000001054fb6b6 in UASMakeIDTable(unsigned long) ()\n#2  0x00000001054fb81b in UASNewID(TUASScript*) ()\n#3  0x00000001054c0f9d in ASGetPropertyLocal(int, unsigned int, AEDesc const*, unsigned int*) ()\n#4  0x00000001054b7aad in AppleScriptComponent ()\n#5  0x00007fff95704b73 in OSAGetProperty ()\n<\/code><\/pre>\n\n<p>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, <code>OSAGetProperty()<\/code> (and all other OSA calls) should return some sort of error instead of crashing.<\/p>\n\n<p><strong>UPDATE<\/strong><\/p>\n\n<p>If, like me, you wrap your OSAIDs in an Objective-C object, make sure your autorelease pool(s) drain properly.  You&#8217;re call to <code>OSADispose()<\/code> probably happens when your object is dealloced and that may not happen when you expect.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>As a followup to my <a href=\"http:\/\/blog.latenightsw.com\/?p=836\">Getting Yosemite AppleScript Progress Information<\/a> post I would like to offer this PSA.<\/p><div class=\"more-link-wrapper\"><a class=\"more-link\" href=\"http:\/\/markalldritt.com\/?p=893\">Continue Reading<span class=\"screen-reader-text\">OSAID Leaks Cause Crashes<\/span><\/a><\/div>","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false}}},"categories":[6,8,15],"tags":[],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p7AQk-ep","_links":{"self":[{"href":"http:\/\/markalldritt.com\/index.php?rest_route=\/wp\/v2\/posts\/893"}],"collection":[{"href":"http:\/\/markalldritt.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/markalldritt.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/markalldritt.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/markalldritt.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=893"}],"version-history":[{"count":4,"href":"http:\/\/markalldritt.com\/index.php?rest_route=\/wp\/v2\/posts\/893\/revisions"}],"predecessor-version":[{"id":897,"href":"http:\/\/markalldritt.com\/index.php?rest_route=\/wp\/v2\/posts\/893\/revisions\/897"}],"wp:attachment":[{"href":"http:\/\/markalldritt.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=893"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/markalldritt.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=893"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/markalldritt.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=893"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}