Unable to understand watchkit extension crash - swift

I am getting these crash reports on Xcode organizer from users of the app. It does not show any line of my code in the crash, looks like it crashed on init. I do not know how to progress with the debug. Can you please help:
Thread 0#0 (null) in 0x300000 ()
#1 (null) in 0x300000 ()
#2 (null) in _WKInterfaceControllerCreateClass ()
#3 (null) in __115-[SPRemoteInterface createViewController:className:properties:contextID:info:gestureDescriptions:clientIdentifier:]_block_invoke_3 ()
#4 (null) in __115-[SPRemoteInterface createViewController:className:properties:contextID:info:gestureDescriptions:clientIdentifier:]_block_invoke_2 ()
#5 (null) in spUtils_dispatchAsyncToMainThread ()
#6 (null) in __115-[SPRemoteInterface createViewController:className:properties:contextID:info:gestureDescriptions:clientIdentifier:]_block_invoke ()
#7 (null) in -[SPRemoteInterface performAfterApplicationDidFinishLaunching:] ()
#8 (null) in -[SPRemoteInterface createViewController:className:properties:contextID:info:gestureDescriptions:clientIdentifier:] ()
#9 (null) in __140-[SPExtensionConnection interfaceViewController:createCompanionControllerClass:properties:initializationContextID:info:gestureDescriptions:]_block_invoke ()
#10 (null) in __62-[SPExtensionConnection performOnSendQueue:syncIfUnsuspended:]_block_invoke.583 ()
#11 (null) in spUtils_dispatchAsyncToMainThread ()
#12 (null) in -[SPExtensionConnection performOnSendQueue:syncIfUnsuspended:] ()
#13 (null) in -[SPExtensionConnection interfaceViewController:createCompanionControllerClass:properties:initializationContextID:info:gestureDescriptions:] ()
#14 (null) in -[SPApplicationDelegate interfaceViewController:createCompanionControllerClass:properties:initializationContextID:] ()
#15 (null) in -[SPInterfaceViewController loadView] ()
#16 (null) in -[UIViewController loadViewIfRequired] ()
#17 (null) in -[UIViewController view] ()
#18 (null) in -[SPModalViewController setContentViewController:] ()
#19 (null) in -[SPApplicationDelegate extensionConnection:interfaceViewController:presentViewController:info:initializationContextID:] ()
#20 (null) in -[SPExtensionConnection handlePlistDictionary:] ()
#21 (null) in -[SPExtensionConnection handleProtoPlist:] ()
#22 (null) in __43-[SPExtensionConnection receiveData:reply:]_block_invoke ()
#23 (null) in spUtils_dispatchAsyncToMainThread ()
#24 (null) in -[SPExtensionConnection receiveData:reply:] ()
#25 (null) in -[SPRemoteInterface performForClientConnections:directToUIBlock:] ()
#26 (null) in __54-[SPRemoteInterface sendData:clientIdentifiers:reply:]_block_invoke ()
#27 (null) in spUtils_dispatchAsyncToMainThread ()
#28 (null) in -[SPRemoteInterface sendData:clientIdentifiers:reply:] ()
#29 (null) in -[SPRemoteInterface sendData:clientIdentifiers:] ()
#30 (null) in -[SPRemoteInterface sendPlist:clientIdentifiers:] ()
#31 (null) in -[SPRemoteInterface controller:presentInterfaceController:initializationContextID:] ()
#32 (null) in +[SPRemoteInterface controller:presentInterfaceController:context:] ()
#33 (null) in __59-[WKInterfaceController presentControllerWithName:context:]_block_invoke ()
#34 (null) in -[WKInterfaceController presentControllerWithName:context:] ()

I had a similar issue. In my case, the issue was that I changed the watch app extension name, so it doesn't include the underscore character. After this, I experienced this crash.
The solution was, to go into the storyboard file of the watch app extension, and in the identity inspector of the existing view controllers, I just retyped the name of the custom class names, and the module updated automatically. After this, it worked. Hope it works for you as well.

Just FYI. The issue that I had was one of those embarrassing ones.
The storyboard had "Inherit Module From Target" on.
However, the default layout that Apple creates, has the executable in a separate (Extension) target.
I need to uncheck that box, and explicitly reference my extension target.
D'oh!

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.

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.

iphone simulator crash

My app crashes only in simulator , it doesn't crash on device.
it crashes in simulator and gives me nothing except this :
#0 0x00000000 in 0x00000000 ()
#1 0x0182966e in icu::RuleBasedBreakIterator::handleNext ()
#2 0x018293dc in icu::RuleBasedBreakIterator::next() ()
#3 0x01828a12 in icu::RuleBasedBreakIterator::following(int) ()
#4 0x043378dd in WebCore::nextBreakablePosition(unsigned short const*, int, int, bool) ()
#5 0x04cc2fca in -[NSString(WebStringDrawing) __web_drawInRect:withFont:ellipsis:alignment:letterSpacing:lineSpacing:includeEmoji:truncationRect:measureOnly:renderedStringOut:] ()
#6 0x04cc07be in -[NSString(WebStringDrawing) __web_drawInRect:withFont:ellipsis:alignment:letterSpacing:lineSpacing:includeEmoji:truncationRect:measureOnly:] ()
#7 0x04cc0499 in -[NSString(WebStringDrawing) _web_drawInRect:withFont:ellipsis:alignment:lineSpacing:includeEmoji:truncationRect:measureOnly:] ()
#8 0x04cc021b in -[NSString(WebStringDrawing) _web_sizeInRect:withFont:ellipsis:lineSpacing:] ()
#9 0x0053fc33 in -[NSString(UIStringDrawing) sizeWithFont:constrainedToSize:lineBreakMode:lineSpacing:] ()
#10 0x00644987 in -[UILabel _drawTextInRect:baselineCalculationOnly:] ()
#11 0x006422fc in -[UILabel drawTextInRect:] ()
#12 0x00559187 in -[UIView(CALayerDelegate) drawLayer:inContext:] ()
#13 0x00221b5e in -[CALayer drawInContext:] ()
#14 0x0022de47 in backing_callback(CGContext*, void*) ()
#15 0x0017b1f7 in CABackingStoreUpdate ()
#16 0x0022dd24 in -[CALayer _display] ()
#17 0x0022427d in CALayerDisplayIfNeeded ()
#18 0x001c90c3 in CA::Context::commit_transaction(CA::Transaction*) ()
#19 0x001ca294 in CA::Transaction::commit() ()
#20 0x001ca555 in CA::Transaction::release_thread(void*) ()
#21 0x98f4de0c in _pthread_tsd_cleanup ()
#22 0x98f0664c in _pthread_exit ()
#23 0x98f069a0 in pthread_exit ()
#24 0x00c93d1a in -[NSString compare:options:] ()
#25 0x00c93c98 in __NSThread__main__ ()
#26 0x98f04ed9 in _pthread_start ()
#27 0x98f086de in thread_start ()
Why is this happening?
Thanks.
Set NSZombieEnabled, MallocStackLogging, and guard malloc in the debugger. Then, when your App crashes, type this in the gdb console:
(gdb) info malloc-history 0x543216
Replace 0x543216 with the address of the object that caused the crash, and you will get a much more useful stack trace and it should help you pinpoint the exact line in your code that is causing the problem.
See this article for more detailed instructions.
Another idea is to try turning off auto-correction in the simulator Settings App.

Xcode malloc error - stack looks weird

I'm using cocos2d and I load all my sprites and scenes before my game. However, once loaded, it seems if I click to start the game too quickly I get this crash:
malloc: *** error for object 0x65cdbb4: incorrect checksum for freed object - object was probably modified after being freed.
*** set a breakpoint in malloc_error_break to debug
So I did what it suggested, recreated the crash and the stack shows this:
#0 0x9033df7e in malloc_error_break ()
#1 0x9033f128 in szone_error ()
#2 0x9033f29b in free_list_checksum_botch ()
#3 0x9024c186 in tiny_malloc_from_free_list ()
#4 0x9024b2a1 in szone_malloc_should_clear ()
#5 0x9024b148 in malloc_zone_malloc ()
#6 0x90249218 in malloc ()
#7 0x97145617 in operator new ()
#8 0x03adc43f in llvm::User::operator new ()
#9 0x03aab18f in llvm::CastInst::Create ()
#10 0x0341394c in llvm::BitcodeReader::ParseFunctionBody ()
#11 0x034164fe in llvm::BitcodeReader::materializeFunction ()
#12 0x0cd72472 in glvmAddOperation ()
#13 0x0cd4c752 in gleBuildVertexSubmitFunc ()
#14 0x0cd74e0c in cvmsModularBuilder ()
#15 0x03392a67 in cvmsCompBuildModularFunction ()
#16 0x033970a8 in cvmsServerBuildModularFunction ()
#17 0x03394e26 in CVMSBuildModularFunction ()
#18 0x032b0c26 in glvm_deferred_build_modular ()
#19 0x03310404 in glvmDoWork ()
#20 0x902747fd in _pthread_start ()
#21 0x90274682 in thread_start ()
None of these functions listed are mine, any ideas? Thanks.

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

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?