xcode: can't show the exact line of the fault - iphone

I am keep seeing such errors but the xcode never shows the line that the error actually happened on, how to set the xcode to show the fault line directly? Till now it just point to the main function.
2012-06-27 21:46:33.513 Chapeng[838:f803] -[SendGiftViewController giftButtonClicked]: unrecognized selector sent to instance 0x6e392a0
The backtrace:
(lldb) bt
* thread #1: tid = 0x1f03, 0x92f359c6 libsystem_kernel.dylib`__pthread_kill + 10, stop reason = signal SIGABRT
frame #0: 0x92f359c6 libsystem_kernel.dylib`__pthread_kill + 10
frame #1: 0x916e6f78 libsystem_c.dylib`pthread_kill + 106
frame #2: 0x916d7bdd libsystem_c.dylib`abort + 167
frame #3: 0x01e38e78 libc++abi.dylib`_Unwind_DeleteException
frame #4: 0x01e3689e libc++abi.dylib`_ZL17default_terminatev + 34
frame #5: 0x01c94f17 libobjc.A.dylib`_objc_terminate + 94
frame #6: 0x01e368de libc++abi.dylib`_ZL19safe_handler_callerPFvvE + 13
frame #7: 0x01e36946 libc++abi.dylib`std::terminate() + 23
frame #8: 0x01e37b3e libc++abi.dylib`__cxa_rethrow + 83
frame #9: 0x01c94e15 libobjc.A.dylib`objc_exception_rethrow + 47
frame #10: 0x01612de0 CoreFoundation`CFRunLoopRunSpecific + 304
frame #11: 0x01612c9b CoreFoundation`CFRunLoopRunInMode + 123
frame #12: 0x0222b7d8 GraphicsServices`GSEventRunModal + 190
frame #13: 0x0222b88a GraphicsServices`GSEventRun + 103
frame #14: 0x0061b626 UIKit`UIApplicationMain + 1163
frame #15: 0x00001ec2 Chapeng`main + 130 at main.m:16
(lldb)

Add a symbolic breakpoint on objc-exception-throw. A tutorial on this is available here. This should make GDB / LLDB stop execution when an unrecognized selector is sent.
EDIT: after reading your backtrace, it appears you have an invalid IB connection. Check all of your buttons on your view controller, and make sure they are linked to a proper selector.

Press cmd+shift+f and paste giftButtonClicked. It will show the list of string in your project find where you have called this method from any class. This error will raise because giftButtonClicked method was not recognizable at the time of calling

Related

How to debug with breakpoint when crash line is the App Delegate?

Ever since upgrading to the latest Xcode, I've experienced random/intermittent crashes on app launch that I can only reproduce by launching the app n times and waiting for it to return. The line that the app crashes on is the top of the App Delegate:
class AppDelegate: UIResponder, UIApplicationDelegate {
I don't know how I'd set a breakpoint here and what I could gather from it. The reported cause of the crash is an NSException error on Thread 1:
[_NSTaggedDate countByEnumeratingWithState:objects:count]: unrecognized selector sent to instance 0x8000000000000000
Backtrace:
* thread #1, queue = 'com.apple.main-thread', stop reason = signal SIGABRT
* frame #0: 0x000000019b7c6d88 libsystem_kernel.dylib`__pthread_kill + 8
frame #1: 0x000000019b6df1e8 libsystem_pthread.dylib`pthread_kill$VARIANT$mp + 136
frame #2: 0x000000019b632934 libsystem_c.dylib`abort + 100
frame #3: 0x000000019b79acc0 libc++abi.dylib`abort_message + 128
frame #4: 0x000000019b78ce10 libc++abi.dylib`demangling_terminate_handler() + 296
frame #5: 0x000000019b6f3e80 libobjc.A.dylib`_objc_terminate() + 124
frame #6: 0x000000019b79a14c libc++abi.dylib`std::__terminate(void (*)()) + 16
frame #7: 0x000000019b79a0e4 libc++abi.dylib`std::terminate() + 44
frame #8: 0x000000019b6f3e04 libobjc.A.dylib`objc_terminate + 12
frame #9: 0x0000000105e2b744 libdispatch.dylib`_dispatch_client_callout + 36
frame #10: 0x0000000105e39710 libdispatch.dylib`_dispatch_main_queue_callback_4CF + 976
frame #11: 0x000000019b94f7fc CoreFoundation`__CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 12
frame #12: 0x000000019b94a6d0 CoreFoundation`__CFRunLoopRun + 1724
frame #13: 0x000000019b949ce8 CoreFoundation`CFRunLoopRunSpecific + 424
frame #14: 0x00000001a5a9438c GraphicsServices`GSEventRunModal + 160
frame #15: 0x000000019fa78444 UIKitCore`UIApplicationMain + 1932
frame #16: 0x0000000100fc866c FXTracker`main at AppDelegate.swift:8:7
frame #17: 0x000000019b7d18f0 libdyld.dylib`start + 4
In the debug navigator window, it's opened to Thread 1 and there is a drop-down called Original Exception Backtrace which looks like this:
0 _exceptionPreprocess
9 Sequence<>.contains(_:)
10 closure #3 in closure #1 in closure #2 in FXEditorViewController.loadBadges()
19 UIApplicationMain
20 main
21 start
Is it safe to say that the crash is caused by closure #3 in closure #1 in closure #2 in loadBadges()?
In this case you can set exception breakpoints
here
and then here (in Exceptions -> All)

How to "Take Priority" of Audio Playback?

I have an audio-playback app that crashes when returning from another audio-playing app when the user attempts to re-start playback. My app works great on it's own and will handle background playback, etc; however when returning from Spotify-like apps it crashes when it starts it's own playback.
I'm guessing there's some sort of "priority" of audio that I should be handling? And taking that priority "back" from whatever audio app previously had it? Just looking for a direction to start looking....thanks!
Backtrace:
thread #1, queue = 'com.apple.main-thread', stop reason = signal SIGABRT
frame #0: 0x00000001be4fdec4 libsystem_kernel.dylib__pthread_kill + 8
frame #1: 0x00000001be41d724 libsystem_pthread.dylibpthread_kill$VARIANT$armv81 + 216
frame #2: 0x00000001be36d844 libsystem_c.dylibabort + 100
frame #3: 0x00000001be4c67d4 libc++abi.dylibabort_message + 128
frame #4: 0x00000001be4c69c4 libc++abi.dylibdemangling_terminate_handler() + 296
frame #5: 0x00000001be42e258 libobjc.A.dylib_objc_terminate() + 124
frame #6: 0x00000001be4d3304 libc++abi.dylibstd::__terminate(void (*)()) + 16
frame #7: 0x00000001be4d2ed8 libc++abi.dylib__cxa_rethrow + 144
frame #8: 0x00000001be42e158 libobjc.A.dylibobjc_exception_rethrow + 40
frame #9: 0x00000001be67eb4c CoreFoundationCFRunLoopRunSpecific + 576
frame #10: 0x00000001c861f328 GraphicsServicesGSEventRunModal + 104
frame #11: 0x00000001c278c63c UIKitCoreUIApplicationMain + 1936
frame #12: 0x00000001047c0e78 Sequencer`main at AppDelegate.swift:23:7
frame #13: 0x00000001be508360 libdyld.dylib`start + 4

iphone app with multiple AVAudioPlayer crashes on iOS 6 upon interruption

I have an app that uses multiple AVAudioPlayer objects to play music. On iOS6, this app crashes when it is interrupted by a incoming phone call. The problem does not occur on iOS 4.3, 5.0 or 5.1. When the app crashes, the following stacktrace was seen.
(lldb) thread backtrace
* thread #1: tid = 0x2403, 0x3b905e64 libsystem_c.dylibpthread_mutex_lock + 388, stop reason = instruction step over
frame #0: 0x3b905e64 libsystem_c.dylibpthread_mutex_lock + 388
frame #1: 0x3299bd18 AVFoundationAVAudioPlayerCpp::sessionPropertyListener(unsigned long, unsigned long, void const*) + 124
frame #2: 0x33200b32 AudioToolboxAudioSessionPropertyListeners::CallPropertyListenersImp(unsigned long, unsigned long, void const*) + 170
frame #3: 0x332008cc AudioToolboxAudioSessionPropertyListeners::CallPropertyListeners(unsigned long, unsigned long, void const*) + 244
frame #4: 0x332b4afc AudioToolboxASCallbackReceiver_AudioSessionInterruptionListenerMessage + 184
frame #5: 0x33389dde AudioToolbox_XAudioSessionInterruptionListenerMessage + 70
frame #6: 0x3320058a AudioToolboxmshMIGPerform + 382
frame #7: 0x337a33e6 CoreFoundation__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 34
frame #8: 0x337a338a CoreFoundation__CFRunLoopDoSource1 + 138
frame #9: 0x337a220e CoreFoundation__CFRunLoopRun + 1382
frame #10: 0x3371523c CoreFoundationCFRunLoopRunSpecific + 356
frame #11: 0x337150c8 CoreFoundationCFRunLoopRunInMode + 104
frame #12: 0x372f433a GraphicsServicesGSEventRunModal + 74
frame #13: 0x356312b8 UIKit`UIApplicationMain + 1120
I have added applicationWillResignActive and this does not get called when the crash occurs. I have also added my app delegate as a delegate to the AVAudioPlayer objects and implemented the audioPlayerBeginInterruption method. This method also does not get called when the crash occurs. If I use only 1 or 2 AVAudioPlayer objects, the crash goes away. The crash occurs with 3 more AVAudioPlayer objects, although only 2 of them are playing at a given time and the remaining have been stopped.
Has anyone seen this kind of problem or have any tips?
Thanks.

Crash when save a photo

I have a strange crash when I save a UIImage into camera roll.
I Use this code:
UIImageWriteToSavedPhotosAlbum (_originalImage, self, #selector(photoSaved:didFinishSavingWithError:contextInfo:), nil);
-(void)photoSaved:(UIImage*)image didFinishSavingWithError:(NSError*)error contextInfo:(void*)contextInfo {
if(!error){
NSLog(#"Photo saved to library!");
} else{
NSLog(#"Saving failed :(");
}
}
This is the Log:
2012-11-10 20:43:29.868 MyApp[5012:1a303] Photo saved to library!
This is the BT:
(lldb) bt
* thread #1: tid = 0x1f03, 0x024e509b libobjc.A.dylib`objc_msgSend + 15, stop reason = EXC_BAD_ACCESS (code=1, address=0x3094a576)
frame #0: 0x024e509b libobjc.A.dylib`objc_msgSend + 15
frame #1: 0x01b84a8b PhotoLibrary`-[PLUILibraryViewController updateNavigationItemButtons] + 216
frame #2: 0x01b6f054 PhotoLibrary`-[PLLibraryViewController(OverridePoints) updateInterfaceForHasContentChange] + 867
frame #3: 0x01c3c228 PhotoLibrary`-[PLAbstractLibraryViewController _updateHasContent] + 295
frame #4: 0x01c3c7d0 PhotoLibrary`-[PLAbstractLibraryViewController _updateAlbumsWithNotification:] + 681
frame #5: 0x01c3b870 PhotoLibrary`-[PLAbstractLibraryViewController albumListDidChange:] + 272
frame #6: 0x01b84c5b PhotoLibrary`-[PLUILibraryViewController albumListDidChange:] + 236
frame #7: 0x01525a29 Foundation`__57-[NSNotificationCenter addObserver:selector:name:object:]_block_invoke_0 + 40
frame #8: 0x0267d855 CoreFoundation`___CFXNotificationPost_block_invoke_0 + 85
frame #9: 0x0267d778 CoreFoundation`_CFXNotificationPost + 1976
frame #10: 0x0146a234 Foundation`-[NSNotificationCenter postNotification:] + 121
frame #11: 0x02d217a4 PhotoLibraryServices`-[PLChangeNotificationCenter _postEnqueuedNotifications] + 425
frame #12: 0x02d1f771 PhotoLibraryServices`-[PLChangeNotificationCenter _sendNotificationsForSplitChanges] + 307
frame #13: 0x02d23614 PhotoLibraryServices`-[PLChangeNotificationCenter managedObjectContext:didProcessRemoteContextSave:usingObjectIDs:] + 56
frame #14: 0x02d017cc PhotoLibraryServices`-[PLSharedManagedObjectContext _mergeChangesFromDidSaveDictionary:usingObjectIDs:] + 229
frame #15: 0x03edfd2f CoreData`__+[NSManagedObjectContext(_NSCoreDataSPI) _mergeChangesFromRemoteContextSave:intoContexts:]_block_invoke_4 + 159
frame #16: 0x03e67d03 CoreData`developerSubmittedBlockToNSManagedObjectContextPerform + 99
frame #17: 0x01af18d9 libdispatch.dylib`_dispatch_barrier_sync_f_slow_invoke + 93
frame #18: 0x01af2509 libdispatch.dylib`_dispatch_main_queue_callback_4CF + 353
frame #19: 0x025e9803 CoreFoundation`__CFRunLoopRun + 2003
frame #20: 0x025e8d84 CoreFoundation`CFRunLoopRunSpecific + 212
frame #21: 0x025e8c9b CoreFoundation`CFRunLoopRunInMode + 123
frame #22: 0x02a2d7d8 GraphicsServices`GSEventRunModal + 190
frame #23: 0x02a2d88a GraphicsServices`GSEventRun + 103
frame #24: 0x00b63626 UIKit`UIApplicationMain + 1163
frame #25: 0x000026ca MyApp`main + 170 at main.m:16
Full disclosure: I hope this makes sense as I'm pretty new to Objective-C, but I recently had a similar problem. I found out that my image was not being retained when I called the didFinishSavingWithError:contextInfo: method after selecting an image from the Camera Roll. What worked for me was adding the withObject: argument to my method call, as shown here:
[self performSelector:#selector(image:didFinishSavingWithError:contextInfo:) withObject:_originalImage];
This way, the image was retained when the didFinishSavgngWithError:contextInfo: method was called where previously it was not. Again, I'm new to Objective-C but I hope that helps...or at least points you in the right direction. What would also be helpful is if you could tell me at what point your app crashes (i.e. when you call the imagePicker, when you select an image from the camera roll, etc.).

Why would a synthesized Getter result in a release?

According to Instruments, my object is sent a release message on this line:
[currentDefaults setObject:self.myArray forKey:#"storedArray"]
This is causing over-release and crash. NSZombies when Profiled found this line and the retain count issue.
But why? The synthesized property is this:
#property (nonatomic, copy) NSArray*myArray;
Why is the line at the top causing the retain count to change?
Here is the backtrace after crash (the line 103 mentioned is the line above):
(lldb) bt
* thread #20: tid = 0x3103, 0x01e31276 CoreFoundation`CFRetain + 22, stop reason = EXC_BREAKPOINT (code=EXC_I386_BPT, subcode=0x0)
frame #0: 0x01e31276 CoreFoundation`CFRetain + 22
frame #1: 0x01eeca00 CoreFoundation`__CFDictionaryStandardRetainValue + 80
frame #2: 0x01e74e62 CoreFoundation`__CFBasicHashReplaceValue + 34
frame #3: 0x01e41964 CoreFoundation`CFBasicHashSetValue + 2628
frame #4: 0x01e40ee3 CoreFoundation`CFDictionarySetValue + 227
frame #5: 0x01e773b5 CoreFoundation`-[CFXPreferencesSource setValue:forKey:] + 85
frame #6: 0x01e8a81e CoreFoundation`-[CFXPreferencesPropertyListSource setValue:forKey:] + 110
frame #7: 0x01e8a72f CoreFoundation`_CFXPreferencesSetValue + 159
frame #8: 0x01e8a5b3 CoreFoundation`CFPreferencesSetAppValue + 51
frame #9: 0x01372ceb Foundation`-[NSUserDefaults(NSUserDefaults) setObject:forKey:] + 100
frame #10: 0x00003922 Ivory Bull Charts`__21-[SavedData saveData]_block_invoke_0 + 178 at SavedData.m:103
frame #11: 0x017a3330 libdispatch.dylib`_dispatch_call_block_and_release + 15
frame #12: 0x017a4439 libdispatch.dylib`_dispatch_worker_thread2 + 302
frame #13: 0x996a3b24 libsystem_c.dylib`_pthread_wqthread + 346
(lldb)
Frankly, just guessing.
In your backtrace there is "CFBasicHashReplaceValue". My guess is that your are not just adding an object with a new key but replacing an existing object that uses the same key within this dictionary.
That existing object would be removed from the dictionary and released. That existing object may have been over-released before this happens.
Make a copy of your arrays or dictionaries and store those in user defaults, rather than the instance variables themselves and see if it prevents retain issues when you re-store the same variable contents to the user defaults.