views:

291

answers:

2

Hi I am debugging my application on iphone (OS 2.0) using X-code 3.1 iphone SDK 3.0 beta 5 . My application crashes giving message * Terminating app due to uncaught exception 'NSRangeException', reason: '* -[NSCFArray insertObject:atIndex:]: index (8) beyond bounds (8)' 2009-05-23 17:13:32.304 myApp[405:5a07] Stack: ( 808163835, 806099672, 807978623, 807978527, 812332907, 812067179, 812067103, 126035, 812081649, 812081343, 826526801 )

In gdb when I give commands (gdb) info line 126035 Line number 126035 is out of range for "/Users/videomac/manish/EXPLab/2009-05-18-12-27 myApp/main.m".

(gdb) info line *126035 Line 527 of "/Users/videomac/manish/EXPLab/2009-05-18-12-27 myApp/Classes/PlaybackThread/Playback.m" starts at address 0x1ec52 <-[Playback startPlaybackThread:]+514> and ends at 0x1ec6a <-[Playback startPlaybackThread:]+538>.

does that means the crash is due to code in my method [Playback startPlaybackThread:] then what is meaning of the no +514 and +538 do they signify line no?

Is there any other way to locate reason of crashes?

+1  A: 

About the first error you mention, from -insertObject:atIndex: documentation:

Important: Raises an NSRangeException if index is greater than the number of elements in the array.

I would look for calls of this method, trying to find which one causes the error.

Numbers +514 and +538 give an offset from the code of instructions just before.

mouviciel
+3  A: 

The easiest way to find where your exception is happening is to set breakpoints on -[NSException raise] and objc_exception_throw in gdb. Then you'll break as soon as it happens, and you can examine the stack at that point.

smorgan
how to set breakpoints on -[NSException raise] and objc_exception_throw in gdb
Rahul Vyas