Jay
Jay

Reputation: 2661

Adding an exception breakpoint causes a crash with no stack trace

I'm working on an app that hasn't transitioned into Swift 4 yet with Xcode 9. I discovered a crash and realized the debugger wasn't printing out the line causing the crash nor the reason behind it. It only printed out there was a NSException.

I started to dive into why this was occurring and found out I should try adding an exception breakpoint. However, whenever I try to do this, the app crashes as it's loading, even when installing for the very first time. Yet, the moment I disable the breakpoint, the app works fine and doesn't crash. I'm unsure of when Xcode stopped printing out descriptive stack traces as well, because this wasn't something that happened in the past, but more of a recent change.

I've looked into my Scheme, I've added po $arg1, po $eax and have directly tried to get the po [$arg1 reason] & [$arg1 name]. I'm unsure of what to do and how to get this working again... any idea why this might be occurring?

EDIT: Was finally able to print out the stacktrace by typing "bt" next (lldb), this is what i get. but i have no idea what it means and it doesn't point to a specific line of code.

thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.2
frame #0: 0x0000000180757e20 libc++abi.dylib`__cxa_throw
frame #1: 0x00000001848e0cb8 libFontParser.dylib`TFileDescriptorContext::TFileDescriptorContext(char const*) + 156
frame #2: 0x00000001849082e4 libFontParser.dylib`TFileDataReference::MapOrRead(char const*, int) + 40
frame #3: 0x00000001848e0ae8 libFontParser.dylib`TFileDataReference::TFileDataReference(char const*) + 
frame #4: 0x00000001848e08f8 libFontParser.dylib`TFileDataSurrogate::TFileDataSurrogate(char const*, bool) + 156
frame #5: 0x00000001849273ec libFontParser.dylib`TFont::CreateFontEntities(char const*, bool, bool&, short, char const*, bool) + 268
frame #6: 0x0000000184928a40 libFontParser.dylib`TFont::CreateFontEntitiesForFile(char const*, bool, bool, short, char const*) + 220
frame #7: 0x00000001848e0364 libFontParser.dylib`FPFontCreateFontsWithPath + 152
frame #8: 0x0000000182cb1fe4 CoreGraphics`create_private_data_array_with_path + 48
frame #9: 0x00000001829f5bd8 CoreGraphics`CGFontCreateFontsWithPath + 36
frame #10: 0x0000000182a45084 CoreGraphics`CGFontCreateFontsWithURL + 372
frame #11: 0x0000000182fa2fc0 GraphicsServices`AddFontsFromURLOrPath + 124
frame #12: 0x0000000182fa663c GraphicsServices`__Initialize_block_invoke + 1020
frame #13: 0x0000000103e1945c libdispatch.dylib`_dispatch_client_callout + 16
frame #14: 0x0000000103e1a17c libdispatch.dylib`dispatch_once_f + 120
frame #15: 0x0000000182fa2ae4 GraphicsServices`Initialize + 272
frame #16: 0x000000018076943c libobjc.A.dylib`CALLING_SOME_+initialize_METHOD + 24
frame #17: 0x0000000180769804 libobjc.A.dylib`_class_initialize + 296
frame #18: 0x0000000180771744 libobjc.A.dylib`lookUpImpOrForward + 228
frame #19: 0x000000018077c758 libobjc.A.dylib`_objc_msgSend_uncached + 56
frame #20: 0x000000018b36ee54 UIKit`-[UIStatusBarForegroundStyleAttributes makeTextFontForStyle:] + 152
frame #21: 0x000000018a6ad3f8 UIKit`-[UIStatusBarForegroundStyleAttributes textFontForStyle:] + 124
frame #22: 0x000000018b36e95c UIKit`-[UIStatusBarForegroundStyleAttributes imageWithText:ofItemType:forWidth:lineBreakMode:letterSpacing:textAlignment:style:withLegibilityStyle:legibilityStrength:] + 312
frame #23: 0x000000018a6ad278 UIKit`-[UIStatusBarItemView imageWithText:] + 260
frame #24: 0x000000018a6ad0cc UIKit`-[UIStatusBarItemView updateContentsAndWidth] + 36
frame #25: 0x000000018a6ba2f0 UIKit`-[UIStatusBarItemView initWithItem:data:actions:style:] + 432
frame #26: 0x000000018a6ba0a8 UIKit`+[UIStatusBarItemView createViewForItem:withData:actions:foregroundStyle:] + 132
frame #27: 0x000000018a6b9f2c UIKit`-[UIStatusBarLayoutManager _createViewForItem:withData:actions:] + 172
frame #28: 0x000000018a6595e4 UIKit`-[UIStatusBarLayoutManager _prepareEnabledItemType:withEnabledItems:withData:actions:itemAppearing:itemDisappearing:] + 332
frame #29: 0x000000018a659420 UIKit`-[UIStatusBarLayoutManager prepareEnabledItems:withData:actions:] + 108
frame #30: 0x000000018a6590d8 UIKit`-[UIStatusBarForegroundView _setStatusBarData:actions:animated:] + 544
frame #31: 0x000000018a658d9c UIKit`-[UIStatusBarForegroundView setStatusBarData:actions:animated:] + 1196
frame #32: 0x000000018ad0ad20 UIKit`__51-[UIStatusBar _prepareToSetStyle:animation:forced:]_block_invoke + 356
frame #33: 0x000000018a671a84 UIKit`+[UIView(Animation) performWithoutAnimation:] + 104
frame #34: 0x000000018ad0a7ac UIKit`-[UIStatusBar _prepareToSetStyle:animation:forced:] + 836
frame #35: 0x000000018ad09748 UIKit`-[UIStatusBar _updateUIWithStyleAttributes:animationParameters:forced:] + 560
frame #36: 0x000000018ad09368 UIKit`-[UIStatusBar _requestStyle:animationParameters:forced:] + 520
frame #37: 0x000000018ae39430 UIKit`-[UIStatusBar_Base requestStyle:animationParameters:forced:] + 96
frame #38: 0x000000018a6e8758 UIKit`-[UIApplication _setStatusBarStyle:animationParameters:] + 168
frame #39: 0x000000018a66aaa8 UIKit`-[UIApplication _updateCurrentStatusBarViewControllerAppearance] + 276
frame #40: 0x000000018a91a7b0 UIKit`-[UIWindow _updateLayerOrderingAndSetLayerHidden:] + 616
frame #41: 0x000000018a6675dc UIKit`-[UIWindow _setHidden:forced:] + 228
frame #42: 0x000000018a6cde98 UIKit`-[UIApplication _createStatusBarWithRequestedStyle:orientation:hidden:] + 664
frame #43: 0x000000018a8cb430 UIKit`-[UIApplication _runWithMainScene:transitionContext:completion:] + 1020
frame #44: 0x000000018ab59454 UIKit`__111-[__UICanvasLifecycleMonitor_Compatability _scheduleFirstCommitForScene:transition:firstActivation:completion:]_block_invoke + 800
frame #45: 0x000000018ae291f0 UIKit`+[_UICanvas _enqueuePostSettingUpdateTransactionBlock:] + 160
frame #46: 0x000000018ab590b8 UIKit`-[__UICanvasLifecycleMonitor_Compatability _scheduleFirstCommitForScene:transition:firstActivation:completion:] + 252
frame #47: 0x000000018ab59928 UIKit`-[__UICanvasLifecycleMonitor_Compatability activateEventsOnly:withContext:completion:] + 748
frame #48: 0x000000018b2c26e8 UIKit`__82-[_UIApplicationCanvas _transitionLifecycleStateWithTransitionContext:completion:]_block_invoke + 260
frame #49: 0x000000018b2c258c UIKit`-[_UIApplicationCanvas _transitionLifecycleStateWithTransitionContext:completion:] + 448
frame #50: 0x000000018b03e9c0 UIKit`__125-[_UICanvasLifecycleSettingsDiffAction performActionsForCanvas:withUpdatedScene:settingsDiff:fromSettings:transitionContext:]_block_invoke + 220
frame #51: 0x000000018b1d3fc8 UIKit`_performActionsWithDelayForTransitionContext + 112
frame #52: 0x000000018b03e870 UIKit`-[_UICanvasLifecycleSettingsDiffAction performActionsForCanvas:withUpdatedScene:settingsDiff:fromSettings:transitionContext:] + 252
frame #53: 0x000000018ae28850 UIKit`-[_UICanvas scene:didUpdateWithDiff:transitionContext:completion:] + 364
frame #54: 0x000000018a8c9e28 UIKit`-[UIApplication workspace:didCreateScene:withTransitionContext:completion:] + 540
frame #55: 0x000000018accd6ec UIKit`-[UIApplicationSceneClientAgent scene:didInitializeWithEvent:completion:] + 364
frame #56: 0x00000001838f5768 FrontBoardServices`-[FBSSceneImpl _didCreateWithTransitionContext:completion:] + 364
frame #57: 0x00000001838fe070 FrontBoardServices`__56-[FBSWorkspace client:handleCreateScene:withCompletion:]_block_invoke_2 + 224
frame #58: 0x0000000103e1945c libdispatch.dylib`_dispatch_client_callout + 16
frame #59: 0x0000000103e25b74 libdispatch.dylib`_dispatch_block_invoke_direct + 268
frame #60: 0x0000000183929a04 FrontBoardServices`__FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 36
frame #61: 0x00000001839296a8 FrontBoardServices`-[FBSSerialQueue _performNext] + 404
frame #62: 0x0000000183929c44 FrontBoardServices`-[FBSSerialQueue _performNextFromRunLoopSource] + 56
frame #63: 0x00000001811fc358 CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 24
frame #64: 0x00000001811fc2d8 CoreFoundation`__CFRunLoopDoSource0 + 88
frame #65: 0x00000001811fbb60 CoreFoundation`__CFRunLoopDoSources0 + 204
frame #66: 0x00000001811f9738 CoreFoundation`__CFRunLoopRun + 1048
frame #67: 0x000000018111a2d8 CoreFoundation`CFRunLoopRunSpecific + 436
frame #68: 0x0000000182fabf84 GraphicsServices`GSEventRunModal + 100
frame #69: 0x000000018a6c7880 UIKit`UIApplicationMain + 208
frame #70: 0x000000010066ffc0 AppName`main at AppDelegate.swift:21
frame #71: 0x0000000180c3e56c libdyld.dylib`start + 4

Upvotes: 2

Views: 504

Answers (1)

Ethan G
Ethan G

Reputation: 1477

DISCLAIMER: This fix is only if you are NOT trying to use custom fonts (i.e. fonts other than System) in the storyboard. If you have custom fonts in your storyboard, then I'm not sure what the issue is. In my case, it was an accident.

Fix by removing custom fonts from storyboard:

I opened my storyboard in Xcode 9 to make some changes. Then I ran the app, and...crash! (Without even getting to the first view controller.) I noticed weird stuff about Font in the stack trace (similar to the stack trace in the question above).

Then I looked at my storyboard's XML file (I just opened the storyboard using vim instead of Xcode) and noticed this block near the top:

<customFonts key="customFonts">
    <array key="HelveticaNeue.ttc">
        <string>HelveticaNeue</string>
    </array>
</customFonts>

This block was automatically added when I opened my storyboard in Xcode 9 because, apparently, I was using a custom font for certain labels.

To fix this, I opened the storyboard in Xcode and searched for "helv" to find all labels where I had accidentally used HelveticaNeue as the font instead of System. Changing all these labels to use System also cause Xcode to automatically remove the block of XML above that was causing the crash.

Hope this helps someone!

Upvotes: 3

Related Questions