Error: *** -[CALayer retain]: message sent to deallocated instance 0xdaa54d0 - iphone

I am working on simple iphone application. where i am working on two views. I pushed the other view controller first and when i am removing the current view as to go back to the old view controller i am getting [CALayer retain]. EXEC_BAD_ACCESS.
In gdb, i tried backtrace command to see the problem which i have given below, but i am not able to find any. If anyone can help me out with this it will be great.
(gdb) backtrace
#0 0x02e21434 in ___forwarding___ ()
#1 0x02e209f2 in __forwarding_prep_0___ ()
#2 0x02dc7f58 in CFRetain ()
#3 0x02dc7a65 in CFArrayCreate ()
#4 0x02dfe043 in -[__NSPlaceholderArray initWithObjects:count:] ()
#5 0x0296eda3 in -[CALayerArray copyWithZone:] ()
#6 0x02ea380a in -[NSObject copy] ()
#7 0x004f742a in -[UIView dealloc] ()
#8 0x00214cb2 in NSPopAutoreleasePool ()
#9 0x004d3698 in _UIApplicationHandleEvent ()
#10 0x035fe17c in PurpleEventCallback ()
#11 0x02df289c in CFRunLoopRunSpecific ()
#12 0x02df18a8 in CFRunLoopRunInMode ()
#13 0x035fc89d in GSEventRunModal ()
#14 0x035fc962 in GSEventRun ()
#15 0x004d1372 in UIApplicationMain ()
#16 0x00002074 in main (argc=1, argv=0xbffff020) at /Users/jtong/Desktop/Elle/main.m:14
Thanks,
Aby

Sounds like you're also explicitly releasing something that you've already autoreleased.

Use Instruments and enable Zombies. This will trace where each object was retained and released and will hell you diagnose where the extra release is occurring.
How to run iPhone program with Zombies instrument?

Related

Can't get past [FBAppCall handleDidBecomeActive]

I'm trying to integrate FB into an existing iOS app.
I've modified the HelloFacebookSample app to use my app ID, display name, and bundle identifier. I can run it and post from it just fine (running in the iOS 6 emulator). So that leads me to believe my settings on developers.facebook.com are correct.
Next I looked at the code in the app delegate and view controller in the sample and duplicated it in my own code. The first bit of Facebook code that gets executed is in the app delegate, in applicationDidBecomeActive:. I execute the same two lines as the sample app:
[FBAppEvents activateApp];
[FBAppCall handleDidBecomeActive];
If I run my program, I eventually get EXC_BAD_ACCESS (code=2, address=0x0). In the debug navigator I see:
#0 0x0253309f in objc_msgSend ()
#1 0x0251eb2e in objc_setProperty_non_gc ()
#2 0x0251ed0d in objc_setProperty ()
#3 0x00446798 in -[FBRequestMetadata setCompletionHandler:] at /Users/chrisp/tmp/build- sdk/ios-sdk/src/FBRequestConnection.m:70
#4 0x004464eb in -[FBRequestMetadata initWithRequest:completionHandler:batchEntryName:] at /Users/chrisp/tmp/build-sdk/ios-sdk/src/FBRequestConnection.m:94
#5 0x00446cb6 in -[FBRequestConnection addRequest:completionHandler:batchEntryName:] at /Users/chrisp/tmp/build-sdk/ios-sdk/src/FBRequestConnection.m:324
#6 0x00446bdb in -[FBRequestConnection addRequest:completionHandler:] at /Users/chrisp/tmp/build-sdk/ios-sdk/src/FBRequestConnection.m:312
#7 0x0044048a in -[FBRequest startWithCompletionHandler:] at /Users/chrisp/tmp/build-sdk/ios-sdk/src/FBRequest.m:149
#8 0x0045ec70 in +[FBUtility fetchAppSettings:callback:] at /Users/chrisp/tmp/build-sdk/ios-sdk/src/FBUtility.m:263
#9 0x0046e06b in +[FBSettings publishInstall:withHandler:isAutoPublish:] at /Users/chrisp/tmp/build-sdk/ios-sdk/src/FBSettings.m:334
#10 0x0046dc0c in +[FBSettings autoPublishInstallImpl:] at /Users/chrisp/tmp/build-sdk/ios-sdk/src/FBSettings.m:217
#11 0x00e27e83 in __NSFireDelayedPerform ()
#12 0x02a9d376 in __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ ()
#13 0x02a9ce06 in __CFRunLoopDoTimer ()
#14 0x02a84a82 in __CFRunLoopRun ()
#15 0x02a83f44 in CFRunLoopRunSpecific ()
#16 0x02a83e1b in CFRunLoopRunInMode ()
#17 0x0339f7e3 in GSEventRunModal ()
#18 0x0339f668 in GSEventRun ()
#19 0x0120665c in UIApplicationMain ()
#20 0x0000230d in main at /Users/craig/Documents/Projects/MyProject/main.m:14
If I remove [FBAppCall handleDidBecomeActive] I get the same result. So this seems to be a result of [FBAppEvents activateApp].
If I remove [FBAppEvents activateApp], which I understand to be optional anyway, and only call [FBAppCall handleDidBecomeActive], I can launch the app. But then when I try to create an instance of FBLoginView in my view controller:
FBLoginView * loginview = [[FBLoginView alloc] init];
I get the same error (EXC_BAD_ACCESS (code=2, address=0x0)):
#0 0x0253309f in objc_msgSend ()
#1 0x0251eb2e in objc_setProperty_non_gc ()
#2 0x0251ed0d in objc_setProperty ()
#3 0x0046d47d in -[FBLoginView setSessionStateHandler:] at /Users/chrisp/tmp/build-sdk/ios-sdk/src/FBLoginView.m:52
#4 0x0046b6f8 in -[FBLoginView initializeBlocks] at /Users/chrisp/tmp/build-sdk/ios-sdk/src/FBLoginView.m:177
#5 0x0046ba1c in -[FBLoginView initialize] at /Users/chrisp/tmp/build-sdk/ios-sdk/src/FBLoginView.m:212
#6 0x0046b432 in -[FBLoginView initWithFrame:] at /Users/chrisp/tmp/build-sdk/ios-sdk/src/FBLoginView.m:119
#7 0x0124528f in -[UIView init] ()
#8 0x0046b252 in -[FBLoginView init] at /Users/chrisp/tmp/build-sdk/ios-sdk/src/FBLoginView.m:80
#9 0x0001c0ea in -[MyViewController postToFacebook:] at /Users/craig/Documents/Projects/MyProject/Classes/MyViewController.mm:8040
#10 0x00015c18 in -[MyViewController copy:to:] at /Users/craig/Documents/Projects/MyProjects/Classes/MyViewController.mm:6624
#11 0x000225ee in -[MyViewController menuItemSelected:] at /Users/craig/Documents/Projects/MyProjects/Classes/MyViewController.mm:10003
#12 0x00e27e83 in __NSFireDelayedPerform ()
#13 0x02a9d376 in __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ ()
#14 0x02a9ce06 in __CFRunLoopDoTimer ()
#15 0x02a84a82 in __CFRunLoopRun ()
#16 0x02a83f44 in CFRunLoopRunSpecific ()
#17 0x02a83e1b in CFRunLoopRunInMode ()
#18 0x0339f7e3 in GSEventRunModal ()
#19 0x0339f668 in GSEventRun ()
#20 0x0120665c in UIApplicationMain ()
#21 0x0000230d in main at /Users/craig/Documents/Projects/MyProject/main.m:14
Don't be fooled by the fact that I'm obviously not creating my FBLoginView in viewDidLoad. The point is that the first call to anything that tries to do anything with my Facebook session fails in the same way. It looks like it's trying to do something with a handler in both cases. The identical code works with MY Facebook identifier, bundle ID, etc. in the sample code, but doesn't work in my app. I'm suspecting compiler/linker settings or some other configuration difference between my app and the sample, but I'm not sure where to begin to look. Everything I've looked at looks the same between my app and the sample.
I've tried a lot of different ways to open a Facebook session and get the permissions I need, but they all fail the same way. This seemed like a good one to post here since the sample works but the same code in my app doesn't.
Thanks for your help.
EDIT: I see in my build settings that the sample app uses ARC. I do not. I'm hesitant to convert a large, functioning app at this point in its lifecycle.

CLLocationManager

I have two location managers, one on a view controller with a map the other one in a separate controller that I present as modal. The issue is that every time I present that modal controller, I get a crash with the following backtrace.
I've tried setting delegates to nil, or setting the actual location manager to nil on viewWillDisappear and then re-initialising them on viewWillAppear, but still the issue persists. Any help would be greatly appreciated.
#0 0x9105fafa in mach_msg_trap ()
#1 0x91060267 in mach_msg ()
#2 0x016d313a in __CFRunLoopServiceMachPort ()
#3 0x01636580 in __CFRunLoopRun ()
#4 0x01635db4 in CFRunLoopRunSpecific ()
#5 0x01635ccb in CFRunLoopRunInMode ()
#6 0x026a6879 in GSEventRunModal ()
#7 0x026a693e in GSEventRun ()
#8 0x003e1a9b in UIApplicationMain ()
#9 0x000028b2 in main (argc=1, argv=0xbfffeca4) at /Users/penushlievm/Desktop/DailyPlanner 2/DailyPlanner 2/main.m:16
#10 0x00002825 in start ()
try using one location manager globally instead of two.

iOS and unarchiving xib files

I'm finishing off an app for iOS 3.0 and up to run on the iPhone and iPod Touch. It's working fine on iOS4.0 and up, but when I backtest it on a second generation iPod Touch running iOS 3.0 the launch image shows and I'm met with the following:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSKeyedUnarchiver initForReadingWithData:]: incomprehensible archive (0x4e, 0x49, 0x42, 0x41, 0x72, 0x63, 0x68, 0x69)'
2012-01-15 09:35:53.025 MyApp[3026:207] Stack: (
808001701,
805397928,
807551015,
807550919,
810902709,
815043196,
815042704,
814682908,
814682012,
814970032,
814968048,
814966908,
839149932,
807750263,
807747947,
814678868,
814672532,
61527,
10764
)
terminate called after throwing an instance of 'NSException'
(gdb) backtrace
#0 0x31dd594c in __kill ()
#1 0x31dd5940 in kill ()
#2 0x31dd5934 in raise ()
#3 0x31deccfe in abort ()
#4 0x374ef848 in __gnu_cxx::__verbose_terminate_handler ()
#5 0x300166c0 in _objc_terminate ()
#6 0x374ecf3c in __cxxabiv1::__terminate ()
#7 0x374ecfb4 in std::terminate ()
#8 0x374ed0dc in __cxa_throw ()
#9 0x300165e4 in objc_exception_throw ()
#10 0x30224026 in +[NSException raise:format:arguments:] ()
#11 0x30223fc6 in +[NSException raise:format:] ()
#12 0x305564b4 in -[NSKeyedUnarchiver initForReadingWithData:] ()
#13 0x3094927c in -[UINib instantiateWithOptions:owner:loadingResourcesFromBundle:] ()
#14 0x30949090 in -[NSBundle(NSBundleAdditions) loadNibNamed:owner:options:] ()
#15 0x308f131c in -[UIApplication _loadMainNibFile] ()
#16 0x308f0f9c in -[UIApplication _runWithURL:sourceBundleID:] ()
#17 0x309374b0 in -[UIApplication handleEvent:withNewEvent:] ()
#18 0x30936cf0 in -[UIApplication sendEvent:] ()
#19 0x3093687c in _UIApplicationHandleEvent ()
#20 0x3204696c in PurpleEventCallback ()
#21 0x30254a76 in CFRunLoopRunSpecific ()
#22 0x3025416a in CFRunLoopRunInMode ()
#23 0x308f0354 in -[UIApplication _run] ()
#24 0x308eea94 in UIApplicationMain ()
#25 0x0000f056 in main (argc=1, argv=0x2ffff7c8) at ...... Classes/main.m:16
Current language: auto; currently objective-c
Any ideas what this is and how to fix it?
I'm building in Xcode 4.2.1.
PS - The problem is not resolved by cleaning the build or by resaving .xib files. Sometimes the app will get past this stage but will crash for apparently the same reason when it sees a later .xib, say in loading a view controller.
This answer I believe covers what Ikuragames might have given (he's not near his computer). On his behalf, to solve the problem in Xcode 4.2.1 click on the .xib file and in the file properties panel on the right hand side, set the deployment to "iOS 3.0" (in my case) and development to "Interface Builder 3.0" (again in my case). Do this for every single .xib file in the project.
It's worth keeping in mind that Xcode 4.2.1 might well set defaults of "iOS 5.0" for the deployment here, to match the current SDK, and "Xcode 4.1" for the document type. Why Xcode doesn't just match the deployment target with the project deployment target I'm not sure...
If this still doesn't work or you're very paranoid by this stage, catch the exception raised by the NSKeyedUnarchiver when loading the .xib file and there create the view programmatically.

How can I find out why my app is getting SIGKILLed inside UIPasteboard?

Very infrequently, our app is crashing because it receives SIGKILL. The circumstances are different, but the backtrace is always the same:
#0 0x94a00afa in mach_msg_trap ()
#1 0x94a01267 in mach_msg ()
#2 0x00fa9d5c in _UIPasteboardServerContainsTypesAtIndex ()
#3 0x00faa9ae in UIPasteboardServerContainsTypesAtIndex ()
#4 0x00fa5417 in -[UIPasteboard containsPasteboardTypes:] ()
#5 0x00de4054 in -[UITextField canPerformAction:withSender:] ()
#6 0x087038a8 in -[UIResponder(UITextAccessibilityUtilities) _accessibilityHasTextOperations] ()
#7 0x08704df5 in -[UIAccessibilityTextFieldElement _accessibilityHasTextOperations] ()
#8 0x08791dcf in -[NSObject(AXPrivCategory) accessibilityAttributeValue:] ()
#9 0x0878a3b4 in _copyMultipleAttributeValuesCallback ()
#10 0x087c5c95 in _AXXMIGCopyMultipleAttributeValues ()
#11 0x087c0a6c in _XCopyMultipleAttributeValues ()
#12 0x087c8e66 in mshMIGPerform ()
#13 0x020cf1c5 in __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ ()
#14 0x02034022 in __CFRunLoopDoSource1 ()
#15 0x0203290a in __CFRunLoopRun ()
#16 0x02031db4 in CFRunLoopRunSpecific ()
#17 0x02031ccb in CFRunLoopRunInMode ()
#18 0x02a43879 in GSEventRunModal ()
#19 0x02a4393e in GSEventRun ()
#20 0x00d2ba9b in UIApplicationMain ()
#21 0x0000284d in main (argc=1, argv=0xbfffed44) at [myapp]/main.m:14
#22 0x000027c5 in start ()
How would I go about finding out what is causing this crash?
The SIGKILL is sent to apps for any kind of exceptions. Se we have to make an educated guess what the exception reason would be in this case. In the above case it looks like accessibility is checking for a certain kind of pasteboard type to be present.
Since this is happening in Apple code most likely this is a bug in iOS, because the containsPasteboardTypes: method should never throw an exception. Only possibly if the passed parameter is nil, but then the bug would lie in UIAccessibilityTextFieldElement which too is Apple's responsibility.
Long story short: you need to file a radar. As a workaround you can add an #try block around the offending operation. This would catch and ignore the exception.

iOS TableView crash don't know how. Here is the app

In my app that you can download here: http://ge.tt/2DDqfJa
I've started a discussion but is died here iOS TableView crash loading different data
The problem is when I back from viewing the YouTube video to the recipes list, the app crash...
And when i select a category for the second time, where have to load a tableview with different data source, it crash.
This is the crash log
Program received signal: “EXC_BAD_ACCESS”.
(gdb) bt
#0 0x00f0da63 in objc_msgSend ()
#1 0x04b27ca0 in ?? ()
#2 0x00002665 in -[RecipesListController viewWillAppear:] (self=0x4b38a00, _cmd=0x6d81a2, animated=1 '\001') at /Users/claudiocanino/Documents/iOS/CottoMangiato/Classes/RecipesListController.m:67
#3 0x00370c9a in -[UINavigationController _startTransition:fromViewController:toViewController:] ()
#4 0x0036b606 in -[UINavigationController _startDeferredTransitionIfNeeded] ()
#5 0x0037283e in -[UINavigationController pushViewController:transition:forceImmediate:] ()
#6 0x04f49549 in -[UINavigationControllerAccessibility(SafeCategory) pushViewController:transition:forceImmediate:] ()
#7 0x0036b4a0 in -[UINavigationController pushViewController:animated:] ()
#8 0x00003919 in -[CategoryViewController tableView:didSelectRowAtIndexPath:] (self=0x4b27ca0, _cmd=0x6d19e3, tableView=0x500c200, indexPath=0x4b2d650) at /Users/claudiocanino/Documents/iOS/CottoMangiato/Classes/CategoryViewCotroller.m:104
#9 0x0032a794 in -[UITableView _selectRowAtIndexPath:animated:scrollPosition:notifyDelegate:] ()
#10 0x00320d50 in -[UITableView _userSelectRowAtPendingSelectionIndexPath:] ()
#11 0x000337f6 in __NSFireDelayedPerform ()
#12 0x00d8cfe3 in __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ ()
#13 0x00d8e594 in __CFRunLoopDoTimer ()
#14 0x00ceacc9 in __CFRunLoopRun ()
#15 0x00cea240 in CFRunLoopRunSpecific ()
#16 0x00cea161 in CFRunLoopRunInMode ()
#17 0x016e0268 in GSEventRunModal ()
#18 0x016e032d in GSEventRun ()
#19 0x002c342e in UIApplicationMain ()
#20 0x00001c08 in main (argc=1, argv=0xbfffef58) at /Users/claudiocanino/Documents/iOS/CottoMangiato/main.m:15
Another bt log:
(gdb) bt
#0 0x00cd76a1 in __CFBasicHashDeallocate ()
#1 0x00cc2bcb in _CFRelease ()
#2 0x00002dd6 in -[RecipesListController setRecipesArray:] (self=0x6834d50, _cmd=0x4293, _value=0x4e3bc70) at /Users/claudiocanino/Documents/iOS/CottoMangiato/Classes/RecipesListController.m:16
#3 0x00002665 in -[RecipesListController viewWillAppear:] (self=0x6834d50, _cmd=0x6d81a2, animated=1 '\001') at /Users/claudiocanino/Documents/iOS/CottoMangiato/Classes/RecipesListController.m:67
#4 0x00370c9a in -[UINavigationController _startTransition:fromViewController:toViewController:] ()
#5 0x0036b606 in -[UINavigationController _startDeferredTransitionIfNeeded] ()
#6 0x0037283e in -[UINavigationController pushViewController:transition:forceImmediate:] ()
#7 0x091ac549 in -[UINavigationControllerAccessibility(SafeCategory) pushViewController:transition:forceImmediate:] ()
#8 0x0036b4a0 in -[UINavigationController pushViewController:animated:] ()
#9 0x00003919 in -[CategoryViewController tableView:didSelectRowAtIndexPath:] (self=0x4b12970, _cmd=0x6d19e3, tableView=0x5014400, indexPath=0x4b2bd00) at /Users/claudiocanino/Documents/iOS/CottoMangiato/Classes/CategoryViewCotroller.m:104
#10 0x0032a794 in -[UITableView _selectRowAtIndexPath:animated:scrollPosition:notifyDelegate:] ()
#11 0x00320d50 in -[UITableView _userSelectRowAtPendingSelectionIndexPath:] ()
#12 0x000337f6 in __NSFireDelayedPerform ()
#13 0x00d8cfe3 in __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ ()
#14 0x00d8e594 in __CFRunLoopDoTimer ()
#15 0x00ceacc9 in __CFRunLoopRun ()
#16 0x00cea240 in CFRunLoopRunSpecific ()
#17 0x00cea161 in CFRunLoopRunInMode ()
#18 0x016e0268 in GSEventRunModal ()
#19 0x016e032d in GSEventRun ()
#20 0x002c342e in UIApplicationMain ()
#21 0x00001c08 in main (argc=1, argv=0xbfffef58) at /Users/claudiocanino/Documents/iOS/CottoMangiato/main.m:15
Thanks
You have probably tried to access an object which has been released. Search for "NSZombieEnabled" and read up on how to debug over-release problems.
The problem is you are over-releasing objects. Since you're using retain-properties you haven't to release the object when assigning a new object to the property. The old object will be released automatically. So these lines make no sense, delete them:
if (self.recipesArray != nil) {
// Release the arrays
[self.recipesArray release];
[self.recipesNames release];
}
In cellForRowAtIndexPath (RecipesListController) you are releasing rowString. There's no need to do that here. Delete that line and everything should work properly.
NSDictionary *dict = [[NSDictionary alloc] initWithContentsOfFile:path];
self.recipesArray = dict;
[dict release];
in your RecipesListController.m file check 55 line in viewwill appear you are release the object that you never give memory
when i make comment to
//[self.recipesArray release];
//[self.recipesNames release];
then it crash on tableview row check it