Re: Crash in -URLByResolvingBookmarkData::::: in sandboxed app
Re: Crash in -URLByResolvingBookmarkData::::: in sandboxed app
- Subject: Re: Crash in -URLByResolvingBookmarkData::::: in sandboxed app
- From: Andrew Madsen <email@hidden>
- Date: Thu, 27 Feb 2014 12:07:17 -0700
Hi Markus,
We ran into this same problem recently too (http://prod.lists.apple.com/archives/cocoa-dev/2013/Nov/msg00024.html). We spent a quite a bit of time trying to resolve it. After using a DTS incident with Apple, the conclusion was that this is simply a bug in NSURL. It was fixed in 10.9.0, but there’s no simple fix for it on 10.7 and 10.8.
For what it’s worth, I don’t think the crash is specific to app termination. We saw it occasionally, and completely unpredictably, in any code that resolved security scoped bookmarks. I wrote a very simple, small test app that simply obtained bookmarks for a big folder (e.g. ~/Music), then infinitely looped through resolving those bookmarks as quickly as possible. It would reliably crash, usually within an hour, and often much more quickly.
Experimentally, we determined that it only crashes when resolving a bookmark with security scope (ie. passing the NSURLBookmarkResolutionWithSecurityScope option). Our workaround was to add a temporary exception entitlement so we can read the entire filesystem, then resolve our bookmarks without using the security scope option. We still obtain security scoped bookmarks so that we can do away with the whole-hard-drive exception when we move to requiring 10.9. Our app is sandboxed, but not sold on the app store so this works OK. However, the app store review team seems very unlikely to approve an app with an exception entitlement like that. So if you’re intending to sell the app on the app store, the only true fix is probably to require 10.9.
-Andrew Madsen
On Feb 19, 2014, at 8:03 AM, Markus Spoettl <email@hidden> wrote:
> Hi,
>
> I keep getting a crash in my sandboxed app when it terminates. It is not 100% reproducible, but it happens a couple of times a day while working on the app, both when run from Xcode and started from Finder.
>
> Part of the termination cleanup requires me to decode a bookmark that was stored in the user defaults previously (same app, same session).
>
> NSData *data = [[NSUserDefaults standardUserDefaults] objectForKey:@"mykey"];
>
> if ((data != nil) && ([data isKindOfClass:[NSData class]])) {
> BOOL stale = NO;
> result = [NSURL URLByResolvingBookmarkData:data
> options:NSURLBookmarkResolutionWithoutUI |
> NSURLBookmarkResolutionWithoutMounting |
> NSURLBookmarkResolutionWithSecurityScope
> relativeToURL:nil
> bookmarkDataIsStale:&stale
> error:&error];
> }
>
> I call this same method in various places and it works fine, but during app termination it sometimes just crashes.
>
> Has anyone seen this? If so, is there any way to avoid it crashing like that?
>
> I'm on OSX 10.8.5 with Xcode 4.6.3, base SDK is 10.7.
>
> Regards
> Markus
>
> The exception details and callstack of the crash is this:
>
> Exception Type: EXC_BREAKPOINT (SIGTRAP)
> Exception Codes: 0x0000000000000002, 0x0000000000000000
>
> Application Specific Information:
> *** __CFTypeCollectionRetain() called with NULL; likely a collection has been corrupted ***
> Performing @selector(terminate:) from sender NSMenuItem 0x7fb330c2aef0
>
> #0 0x00007fff94b92711 in __CFTypeCollectionRetain ()
> #1 0x00007fff94bbfac2 in __CFDictionaryRetainValue ()
> #2 0x00007fff94b91b8a in __CFBasicHashAddValue ()
> #3 0x00007fff94b98268 in CFBasicHashAddValue ()
> #4 0x00007fff94bcbe5f in CFDictionaryCreate ()
> #5 0x00007fff94bd273c in CFErrorCreateWithUserInfoKeysAndValues ()
> #6 0x00007fff95107ff2 in reportErrorForURL(__CFError**, long, __CFURL const*) ()
> #7 0x00007fff950ef037 in _CFURLCreateByResolvingBookmarkData ()
> #8 0x00007fff94c4ae5e in +[NSURL URLByResolvingBookmarkData:options:relativeToURL:bookmarkDataIsStale:error:] ()
> #9 0x0000000100113588 in -[MyController getURL] at /Users/markus/Projects/MyController.m:187
>
> --
> __________________________________________
> Markus Spoettl
> _______________________________________________
>
> Cocoa-dev mailing list (email@hidden)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden