Seb
Seb

Reputation: 3564

Intermittent NSArray indexing exception

I have a crash that happens at least once a day that I really can't seem to put a finger on. It seems to happen to me at random moments and I can't trace the stack to understand why it happens. If anyone can point me in the proper direction or even show me some online documentation and tutorials on how I can properly trace values that would be perfect. The most that I understand is that something is trying to access an index in an array, but I can't figure out for the life of me what that array can be. I've included the information from the output window below:

2012-09-28 12:45:26.884 TestApp[1683:c07] *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayM objectAtIndex:]: index 0 beyond bounds for empty array'
*** First throw call stack:
(0x1bdd052 0x19ccd0a 0x1bc9db8 0x29522 0x23e76 0x22bed 0x21e36 0xdfee 0xdba8 0xd3cc 0x1bdee72 0x13339ef 0x1bb197f 0x1b14b73 0x1b14454 0x1b13db4 0x1b13ccb 0x2692879 0x269293e 0xa1ba9b 0x2ded 0x2d25)
terminate called throwing an exceptionCurrent language:  auto; currently objective-c
(gdb) bt
#0  0x98468a6a in __pthread_kill ()
#1  0x98554acf in pthread_kill ()
#2  0x9858b4f8 in abort ()
#3  0x021cbe78 in abort_message ()
#4  0x021c989e in default_terminate ()
#5  0x019ccf4b in _objc_terminate ()
#6  0x021c98de in safe_handler_caller ()
#7  0x021c9946 in std::terminate ()
#8  0x021cab3e in __cxa_rethrow ()
#9  0x019cce49 in objc_exception_rethrow ()
#10 0x01b13e10 in CFRunLoopRunSpecific ()
#11 0x01b13ccb in CFRunLoopRunInMode ()
#12 0x02692879 in GSEventRunModal ()
#13 0x0269293e in GSEventRun ()
#14 0x00a1ba9b in UIApplicationMain ()
#15 0x00002ded in main (argc=1, argv=0xbffff39c) at /Users/seb/Desktop/Development/main.m:14

Upvotes: 0

Views: 82

Answers (1)

David Hoerl
David Hoerl

Reputation: 41642

You need to use the Xcode debugger:

  • Tap the Breakpoints button in the toolbar:

Breakpoints button

  • Tap the Breakpoints option in the left pane:

enter image description here

  • Tap the '+' button bottom left, and select 'Add Exception Breakpoint':

enter image description here

  • Tap done in the presented view, and you will see something like this (the top one is disabled):

enter image description here

  • insure your app scheme has lldb enabled:

enter image description here

Upvotes: 2

Related Questions