Nilesh Mahajan
Nilesh Mahajan

Reputation: 617

how to deal with Terminating app due to uncaught exception

Not getting why the app is crashing random time. unable to find any str. Please help.. I am not able to track the issue by this log. please also help me how to deal with such difficult log to track where exactly the issue is.

Terminating app due to uncaught exception 'NSGenericException', reason: '*** Collection <__NSSetM: 0x7fda3c871090> was mutated while being enumerated.'
*** First throw call stack:
(
    0   CoreFoundation                      0x0000000105ed1f35 __exceptionPreprocess + 165
    1   libobjc.A.dylib                     0x0000000104ce1bb7 objc_exception_throw + 45
    2   CoreFoundation                      0x0000000105ed1894 __NSFastEnumerationMutationHandler + 132
    3   Foundation                          0x000000010488e3be -[NSISEngine _coreReplaceMarker:withMarkerPlusDelta:] + 347
    4   Foundation                          0x000000010488e1dc -[NSISEngine constraintDidChangeSuchThatMarker:shouldBeReplacedByMarkerPlusDelta:] + 239
    5   Foundation                          0x000000010488adea -[NSLayoutConstraint _containerGeometryDidChange] + 310
    6   UIKit                               0x0000000103c03a04 ___UITagLayoutConstraintsForConstantChangeForSelectedAttributes_block_invoke + 409
    7   UIKit                               0x0000000103c1027b -[UIView(AdditionalLayoutSupport) _withUnsatisfiableConstraintsLoggingSuspendedIfEngineDelegateExists:] + 115
    8   UIKit                               0x0000000103c03865 _UITagLayoutConstraintsForConstantChangeForSelectedAttributes + 80
    9   UIKit                               0x00000001035ea079 -[UIView _layoutMarginsDidChange] + 60
    10  UIKit                               0x00000001035ea248 -[UIView setLayoutMargins:] + 426
    11  UIKit                               0x00000001036a9296 -[UIViewController _setContentOverlayInsets:] + 270
    12  UIKit                               0x00000001036a9bc7 -[UIViewController _updateContentOverlayInsetsFromParentIfNecessary] + 1857
    13  UIKit                               0x00000001036038cd -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 355
    14  QuartzCore                          0x0000000109d9dde8 -[CALayer layoutSublayers] + 150
    15  QuartzCore                          0x0000000109d92a0e _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 380
    16  QuartzCore                          0x0000000109d9287e _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 24
    17  QuartzCore                          0x0000000109d0063e _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 242
    18  QuartzCore                          0x0000000109d0174a _ZN2CA11Transaction6commitEv + 390
    19  UIKit                               0x000000010358714d _UIApplicationHandleEventQueue + 2035
    20  CoreFoundation                      0x0000000105e07551 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
    21  CoreFoundation                      0x0000000105dfd41d __CFRunLoopDoSources0 + 269
    22  CoreFoundation                      0x0000000105dfca54 __CFRunLoopRun + 868
    23  CoreFoundation                      0x0000000105dfc486 CFRunLoopRunSpecific + 470
    24  GraphicsServices                    0x0000000107a659f0 GSEventRunModal + 161
    25  UIKit                               0x000000010358a420 UIApplicationMain + 1282
    26  HomeDiary                           0x0000000102c861c3 main + 115
    27  libdyld.dylib                       0x0000000106fa5145 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb) bt
* thread #1: tid = 0x1f5db, 0x00000001072c3286 libsystem_kernel.dylib`__pthread_kill + 10, queue = 'com.apple.main-thread', stop reason = signal SIGABRT
    frame #0: 0x00000001072c3286 libsystem_kernel.dylib`__pthread_kill + 10
    frame #1: 0x00000001072f642f libsystem_pthread.dylib`pthread_kill + 90
    frame #2: 0x000000010705319a libsystem_sim_c.dylib`abort + 129
    frame #3: 0x0000000106e14481 libc++abi.dylib`abort_message + 257
    frame #4: 0x0000000106e3c3d5 libc++abi.dylib`default_terminate_handler() + 267
    frame #5: 0x0000000104ce1e19 libobjc.A.dylib`_objc_terminate() + 103
    frame #6: 0x0000000106e39b01 libc++abi.dylib`std::__terminate(void (*)()) + 8
    frame #7: 0x0000000106e397aa libc++abi.dylib`__cxa_rethrow + 99
    frame #8: 0x0000000104ce1d2c libobjc.A.dylib`objc_exception_rethrow + 40
    frame #9: 0x0000000105dfc53e CoreFoundation`CFRunLoopRunSpecific + 654
    frame #10: 0x0000000107a659f0 GraphicsServices`GSEventRunModal + 161
    frame #11: 0x000000010358a420 UIKit`UIApplicationMain + 1282
  * frame #12: 0x0000000102c861c3 HomeDiary`main(argc=1, argv=0x00007fff5cf8e348) + 115 at main.m:16
    frame #13: 0x0000000106fa5145 libdyld.dylib`start + 1

Upvotes: 0

Views: 833

Answers (1)

Fogmeister
Fogmeister

Reputation: 77621

The reason it is crashing is in the first line... Collection <__NSSetM: 0x7fda3c871090> was mutated while being enumerated.

This means you have an NSMutableSet and you are enumerating it for (id someObject in mySet) {} or [mySet enumerateObjects... and inside that enumeration you are mutating the set.

Something like this...

for (id someObject in mySet) {
    [mySet removeObject:someObject];
}

Or something like that. You can't do this, it will crash... hence your crash.

To find where this is happening you need to add an Exception Breakpoint to the project. This will then stop the execution on the line of code causing the crash.

Upvotes: 2

Related Questions