Cocos2d CCSprite Position Deallocated Error - ios

when i run my game with the following code, my game crashes, when the player intersects with the enemy2 and i get the following error in the debug consel.
error:
*** -[CCSprite position]: message sent to deallocated instance 0xa8cabd0
code:
// Check if enemy2 is a child of the layer
if (enemy2) {
CGRect enemy2Rect = CGRectMake(
enemy2.position.x - (enemy2.contentSize.width/2),
enemy2.position.y - (enemy2.contentSize.height/2),
80,
// ERROR HAPPENS HERE Stopped at thread 1
41);
// check if player intersects the enemy
if (CGRectIntersectsRect(playerRect, enemy2Rect)) {
// check if the power up is true
if (bustEmUp == TRUE) {
enemy2Hit = TRUE;
[self unschedule:#selector(collisionDetection)];
[self removeChild:enemy2 cleanup:YES];
id delay = [CCDelayTime actionWithDuration:15];
id addEnemy = [CCCallFunc actionWithTarget:self selector:#selector(addEnemy2)];
[self runAction:[CCSequence actions:delay,addEnemy, nil]];
[self schedule:#selector(collisionDetection) interval:0.01];
} else {
// if not then collide
[self schedule:#selector(collisionAlert)];
}
}
}
heres my backtrace if it helps:
#0 0x01a83e1e in ___forwarding___ ()
#1 0x01a83ce2 in __forwarding_prep_0___ ()
#2 0x000e4fab in -[Survival collisionDetection] (self=0x12b975c0, _cmd=0x14a5e0) at Survival.m:521
#3 0x0005babb in -[CCTimer update:] (self=0x1281af50, _cmd=0x13347c, dt=0.0494979993) at CCScheduler.m:141
#4 0x00064a20 in -[CCScheduler tick:] (self=0xa8c9b70, _cmd=0x13c8fa, dt=0.0494979993) at CCScheduler.m:606
#5 0x0008d9ef in -[CCDirectorIOS drawScene] (self=0x9466d20, _cmd=0x136bdf) at CCDirectorIOS.m:152
#6 0x0008ffda in -[CCDirectorDisplayLink mainLoop:] (self=0x9466d20, _cmd=0x142bcd, sender=0x1208c2b0) at CCDirectorIOS.m:721
#7 0x005e22db in CA::Display::DisplayLink::dispatch ()
#8 0x005e21af in CA::Display::TimerDisplayLink::callback ()
#9 0x01af1966 in __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ ()
#10 0x01af1407 in __CFRunLoopDoTimer ()
#11 0x01a547c0 in __CFRunLoopRun ()
#12 0x01a53db4 in CFRunLoopRunSpecific ()
#13 0x01a53ccb in CFRunLoopRunInMode ()
#14 0x021c8879 in GSEventRunModal ()
#15 0x021c893e in GSEventRun ()
#16 0x00b63a9b in UIApplicationMain ()
#17 0x000c083f in main (argc=1, argv=0xbffff5a0) at main.m:14
heres where i initialized the enemy2:
enemy2 = [CCSprite spriteWithFile:#"SpaceShip2.png"];
enemy2.position = ccp(500,700);
[self addChild:enemy2];

enemy2 has probably been released. It would pass your if(enemy2) check because enemy2 is an address and not nil, but the object at that address has been deallocated.

Related

EXC_BAD_ACCESS when safely unwrapping optional on NSManagedObject

I have the following base NSManagedObject in our Application:
#objc(LaravelEntity)
class LaravelEntity: NSManagedObject {
static func create(moc: NSManagedObjectContext) -> LaravelEntity? {
let entityName = NSStringFromClass(self)
let ent = NSEntityDescription.insertNewObject(forEntityName: entityName, into: moc) as? LaravelEntity
// We set local changes to true, so it will definitely be pushed to the server
ent?.local_changes = true
return ent
}
static func lastUpdatedRequest() -> NSFetchRequest<LaravelEntity> {
let request : NSFetchRequest<LaravelEntity> = self.self.fetchRequest()
let sort = NSSortDescriptor(key: #keyPath(LaravelEntity.updated_at), ascending: false)
request.sortDescriptors = [sort]
request.fetchLimit = 1
return request
}
}
I also have some subclasses of this. They are defined as subclasses in the DataModel as well:
#objc(Answer)
class Answer: LaravelEntity {
}
I try to fetch the last updated entity for a given class like this:
func lastUpdated(klass: LaravelEntity.Type, ctx : NSManagedObjectContext? = nil) -> LaravelEntity? {
do {
let request = klass.lastUpdatedRequest()
let result = try ctx?.fetch(request) ?? self.persistentContainer.newBackgroundContext().fetch(request)
return result.first
} catch {
print("Error while fetching last updated: \(error)!")
}
return nil
}
This works great for the most part. However, sporadically the application just crashes when trying to do something as simple as querying the id: lastUpdated?.id == 1. I have no idea why this would crash, as all optionals are safely handled (as far as I can tell). Also, when looking at the objects in the debugger, they display fine (e.g. po lastUpdated?.id == 1 returns true in the debugger).
I have created the following example test case to reproduce the problem, somewhat consistently:
func testLastUpdated() {
for i in 0...1000 {
let cases = [Location.self, Position.self, Answer.self, Question.self]
for kase in cases {
let old = kase.create(moc: sm.persistentContainer.viewContext)
let new = kase.create(moc: sm.persistentContainer.viewContext)
XCTAssert(old != nil, "Couldn't create old \(kase) object!")
XCTAssert(new != nil, "Couldn't create new \(kase) object!")
old?.updated_at = Date(timeIntervalSinceNow: TimeInterval(-60*60*24 + i * 60))
old?.id = Int32(i*2)
new?.updated_at = Date(timeIntervalSinceNow: TimeInterval(i*60))
new?.id = Int32(i*2+1)
try! sm.persistentContainer.viewContext.save()
let last_updated = sm.lastUpdated(klass: kase)
XCTAssert(last_updated?.id == new?.id, "Last updated \(kase) doesn't have the correct id \(last_updated?.id ?? -1) vs \(new?.id ?? -1)!") //It crashes on this line.
}
}
}
However, even with a 1000 repetitions, it only crashes about 1/3 of the time I run the test. Additionally, it only crashes in the low 50s of iterations.
The following is the callstack when running the above test:
#0 0x00000001857f8430 in objc_msgSend ()
#1 0x0000000188e1f274 in -[NSPersistentStoreCoordinator _canRouteToStore:forContext:] ()
#2 0x0000000188e21f38 in __110-[NSPersistentStoreCoordinator(_NSInternalMethods) newValueForRelationship:forObjectWithID:withContext:error:]_block_invoke ()
#3 0x0000000188e29af0 in gutsOfBlockToNSPersistentStoreCoordinatorPerform ()
#4 0x0000000185f19048 in _dispatch_client_callout ()
#5 0x0000000185f5b760 in _dispatch_sync_invoke_and_complete_recurse ()
#6 0x0000000185f5b26c in _dispatch_sync_wait ()
#7 0x0000000188e17f74 in _perform ()
#8 0x0000000188e17d2c in -[NSPersistentStoreCoordinator _routeLightweightBlock:toStore:] ()
#9 0x0000000188d4bc94 in -[NSPersistentStoreCoordinator(_NSInternalMethods) newValueForRelationship:forObjectWithID:withContext:error:] ()
#10 0x0000000188d34d7c in _PFFaultHandlerFulfillFault ()
#11 0x0000000188d32a80 in _PFFaultHandlerLookupRow ()
#12 0x0000000188d32334 in _PF_FulfillDeferredFault ()
#13 0x0000000188dd7644 in _pvfk_header ()
#14 0x0000000188dd7450 in _sharedIMPL_pvfk_core_i ()
#15 0x00000001092484a4 in implicit closure #5 in SyncManagerTests.testLastUpdated() at CDTests.swift:74
#16 0x00000001092589d4 in partial apply for implicit closure #5 in SyncManagerTests.testLastUpdated() ()
#17 0x00000001092a5bdc in partial apply for closure #1 in XCTAssertTrue(_:_:file:line:) ()
#18 0x00000001092a5448 in partial apply for closure #1 in _XCTRunThrowableBlock(_:) ()
#19 0x0000000109290224 in thunk for #callee_owned () -> () ()
#20 0x00000001092a6048 in _XCTRunThrowableBlockBridge ()
#21 0x00000001092943bc in specialized _XCTRunThrowableBlock(_:) ()
#22 0x0000000109296118 in specialized XCTAssertTrue(_:_:file:line:) ()
#23 0x000000010929045c in XCTAssert(_:_:file:line:) ()
#24 0x0000000109248010 in SyncManagerTests.testLastUpdated() at CDTests.swift:74
#25 0x0000000109248aa8 in #objc SyncManagerTests.testLastUpdated() ()
#26 0x000000018659d670 in __invoking___ ()
#27 0x000000018647c6cc in -[NSInvocation invoke] ()
#28 0x0000000107996654 in __24-[XCTestCase invokeTest]_block_invoke.275 ()
#29 0x00000001079e4208 in -[XCTMemoryChecker _assertInvalidObjectsDeallocatedAfterScope:] ()
#30 0x0000000107996404 in __24-[XCTestCase invokeTest]_block_invoke ()
#31 0x00000001079dc9d8 in -[XCUITestContext performInScope:] ()
#32 0x000000010799614c in -[XCTestCase invokeTest] ()
#33 0x0000000107997224 in __26-[XCTestCase performTest:]_block_invoke.382 ()
#34 0x00000001079e1a78 in +[XCTContext runInContextForTestCase:block:] ()
#35 0x0000000107996c20 in -[XCTestCase performTest:] ()
#36 0x0000000107992e14 in __27-[XCTestSuite performTest:]_block_invoke ()
#37 0x000000010799283c in -[XCTestSuite _performProtectedSectionForTest:testSection:] ()
#38 0x0000000107992a4c in -[XCTestSuite performTest:] ()
#39 0x0000000107992e14 in __27-[XCTestSuite performTest:]_block_invoke ()
#40 0x000000010799283c in -[XCTestSuite _performProtectedSectionForTest:testSection:] ()
#41 0x0000000107992a4c in -[XCTestSuite performTest:] ()
#42 0x0000000107992e14 in __27-[XCTestSuite performTest:]_block_invoke ()
#43 0x000000010799283c in -[XCTestSuite _performProtectedSectionForTest:testSection:] ()
#44 0x0000000107992a4c in -[XCTestSuite performTest:] ()
#45 0x00000001079eb484 in __44-[XCTTestRunSession runTestsAndReturnError:]_block_invoke ()
#46 0x00000001079a5994 in -[XCTestObservationCenter _observeTestExecutionForBlock:] ()
#47 0x00000001079eb300 in -[XCTTestRunSession runTestsAndReturnError:] ()
#48 0x00000001079823d4 in -[XCTestDriver runTestsAndReturnError:] ()
#49 0x00000001079e0c20 in _XCTestMain ()
#50 0x000000018653e0fc in __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ ()
#51 0x000000018653d9cc in __CFRunLoopDoBlocks ()
#52 0x000000018653b6dc in __CFRunLoopRun ()
#53 0x000000018645bfb8 in CFRunLoopRunSpecific ()
#54 0x00000001882f3f84 in GSEventRunModal ()
#55 0x000000018fa302e8 in UIApplicationMain ()
#56 0x000000010137f528 in main at AppDelegate.swift:13
#57 0x0000000185f7e56c in start ()
I have no idea what could cause such a crash, since all optionals are handled correctly.
Edit 1: So the crash definitely happens on the following line last_updated?.id == new?.id (Which still doesn't make any sense to me). Even if I comment out all code changing the objects and only create one object, it still crashes (randomly) on lastUpdated?.id != nil.
Core data is not thread safe. Every context has one and only one thread that is can be read or written from. If you violate this, the behavior is UNDEFINED. Which means that it may crash or it may not. It may wait for 10 minutes and then crash when you do something unrelated.
In your code you are creating a newBackgroundContext inside func lastUpdated (because you are passing a nil context). Doing a fetch with this context is illegal. You can only use this context with performBlock or performBlockAndWait.
Also you have an extra self. in lastUpdatedRequest

Crash in GCDWebServer when app enters background

I'm getting a crash from GCDWebServer (3.3.3) when my app enters the background:
#3 0x000000010041ea80 in -[GCDWebServer dealloc] at project/Pods/GCDWebServer/GCDWebServer/Core/GCDWebServer.m:221
#4 0x00000001004248b8 in __destroy_helper_block_ ()
#5 0x000000018dd52a28 in _Block_release ()
#6 0x00000001020ad21c in _dispatch_client_callout ()
#7 0x00000001020b2284 in _dispatch_main_queue_callback_4CF ()
#8 0x000000018ee21f2c in __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ ()
#9 0x000000018ee1fb18 in __CFRunLoopRun ()
#10 0x000000018ed4e048 in CFRunLoopRunSpecific ()
#11 0x00000001907d1198 in GSEventRunModal ()
#12 0x0000000194d28628 in -[UIApplication _run] ()
#13 0x0000000194d23360 in UIApplicationMain ()
#14 0x000000010009243c in main at project/main.m:10
#15 0x000000018dd305b8 in start ()
Enqueued from com.apple.main-thread (Thread 1)Queue : com.apple.main-thread (serial)
#0 0x00000001020b8ba4 in _dispatch_queue_push ()
#1 0x0000000100424680 in -[GCDWebServer _stop] at project/Pods/GCDWebServer/GCDWebServer/Core/GCDWebServer.m:734
#2 0x0000000100424a10 in -[GCDWebServer _didEnterBackground:] at project/Pods/GCDWebServer/GCDWebServer/Core/GCDWebServer.m:746
The specific line is:
GWS_DCHECK(_options == nil); // The server can never be dealloc'ed while running because of the retain-cycle with the dispatch source
It looks like the _options dictionary has to be nil (eg. the server has to be stopped) but it looks like the _options is never set to nil on this code path: it's set to nil in - stop but not in - _stop.
I'm probably missing something as this would have been noticed by other people.
I had the same problem. I solved it saving the server in a static variable on my class instead of saving in a function.
It doesn't works:
class Server {
static func initialize() {
let webServer = GCDWebServer()
...
webServer?.start(withPort: 8081, bonjourName: nil)
}
}
It's works:
class Server {
static let webServer = GCDWebServer()
static func initialize() {
...
webServer?.start(withPort: 8081, bonjourName: nil)
}
}

Crash in CFRelease when running XCTest unit tests on iOS simulator

This only seems to happen when running unit tests against one of my view controllers, and it's pretty random. Sometimes the test will pass, but most of the time it crashes in the same place.
The following is the stack trace from Xcode:
#0 0x000000010e66727c in CFRelease ()
#1 0x000000011b4b1e00 in 0x11b4b1e00 ()
#2 0x000000010e667268 in CFRelease ()
#3 0x000000010de060b8 in (anonymous namespace)::AutoreleasePoolPage::pop(void*) ()
#4 0x000000011b325c23 in -[XCTestCase performTest:] ()
#5 0x000000011b3238d1 in -[XCTestSuite performTest:] ()
#6 0x000000011b3238d1 in -[XCTestSuite performTest:] ()
#7 0x000000011b3238d1 in -[XCTestSuite performTest:] ()
#8 0x000000011b310adc in __25-[XCTestDriver _runSuite]_block_invoke ()
#9 0x000000011b3312e3 in -[XCTestObservationCenter _observeTestExecutionForBlock:] ()
#10 0x000000011b310a28 in -[XCTestDriver _runSuite] ()
#11 0x000000011b311787 in -[XCTestDriver _checkForTestManager] ()
#12 0x000000011b359b23 in _XCTestMain ()
#13 0x000000010e6c2ffc in __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ ()
#14 0x000000010e6b8c85 in __CFRunLoopDoBlocks ()
#15 0x000000010e6b83e2 in __CFRunLoopRun ()
#16 0x000000010e6b7e08 in CFRunLoopRunSpecific ()
#17 0x0000000111687ad2 in GSEventRunModal ()
#18 0x000000010efad30d in UIApplicationMain ()
#19 0x000000010b76c134 in main at /Users/abc/Projects/xyz/Supporting Files/main.m:14
#20 0x000000011060292d in start ()
#21 0x000000011060292d in start ()
The assembly code near the breakpoint has a reference to a string that seems to be suggesting that a NULL argument was passed to CFRelease:
0x10e667252 <+1170>: callq 0x10e653af0 ; CFAllocatorDeallocate
0x10e667257 <+1175>: cmpq %rbx, %r13
0x10e66725a <+1178>: je 0x10e667013 ; <+595>
0x10e667260 <+1184>: movq %rbx, %rdi
0x10e667263 <+1187>: callq 0x10e666dc0 ; <+0>
0x10e667268 <+1192>: jmp 0x10e667013 ; <+595>
0x10e66726d <+1197>: leaq 0x329469(%rip), %rax ; "*** CFRelease() called with NULL ***"
0x10e667274 <+1204>: movq %rax, 0x35994d(%rip) ; gCRAnnotations + 8
0x10e66727b <+1211>: int3
-> 0x10e66727c <+1212>: jmp 0x10e667282 ; <+1218>
Does anybody have any idea why this could possibly happen?
I'm using Xcode 7.1.
Thanks.
EDIT:
This is roughly what the crashing test looks like:
self.navigationController = [[UINavigationController alloc] init];
self.viewControllerMocks = #{
FixtureViewControllerKey: OCMClassMock([UIViewController class]),
// ... more UIViewController mocks
};
self.menuViewController = [[MenuViewController alloc] initWithInnerNavigationController:self.navigationController initialViewControllerKey:FixtureViewControllerKey viewControllers:self.viewControllerMocks];
(void)self.menuViewController.view;
[self simulateTapOnMenuItemWithTitle:#"Some button"];
XCTAssertEqual(self.navigationController.viewControllers[0],
self.viewControllerMocks[MenuViewControllerSomeKey]);
This is how simulateTapOnMenuItemWithTitle: is defined:
- (void)simulateTapOnMenuItemWithTitle:(NSString *)title {
UIButton *button = [self.menuViewController.view testsFindButtonWithTitle:title];
[button testsSimulateTap];
}
// Helper methods defined in a UIView category
- (UIView *)testsFindSubviewUsingBlock:(BOOL (^)(UIView *subview))block {
for (UIView *subview in self.subviews) {
if (block(subview)) {
return subview;
}
UIView *foundSubview = [subview testsFindSubviewUsingBlock:block];
if (foundSubview != nil) {
return foundSubview;
}
}
return nil;
}
- (UIButton *)testsFindButtonWithTitle:(NSString *)title {
return (UIButton *)[self testsFindSubviewUsingBlock:^BOOL(UIView *subview) {
return [subview isKindOfClass:[UIButton class]] && [((UIButton *)subview).titleLabel.text isEqualToString:title];
}];
}

iPhone app crashes after resigning active state (after core data wipe)

My app uses core data for data storage, and I added code that handles cases where the database/model is not compatible/corrupt/etc. In this case, I will present an error message, prompting the user to wipe all of the data, and restart the app, so the user can start again from scratch.
The problem is, that the app will crash after the storage was deleted and the user pressed the homebutton. My wipe code looks like this:
// destroy context
if ([__managedObjectContext hasChanges])
[__managedObjectContext rollback];
[__managedObjectContext release];
__managedObjectContext = nil;
// remove store
if (__persistentStoreCoordinator.persistentStores.count)
[__persistentStoreCoordinator removePersistentStore:[__persistentStoreCoordinator persistentStoreForURL:localURL] error:nil];
NSLog(#"retain count: %p %d", __persistentStoreCoordinator, __persistentStoreCoordinator.retainCount);
[__persistentStoreCoordinator release];
__persistentStoreCoordinator = nil;
Interestingly the retain count of the NSPersistentStoreCoordinator is 1, therefore the release above will dealloc the object.
When the user now presses the homebutton, I will get this in the console:
*** -[NSPersistentStoreCoordinator retain]: message sent to deallocated instance 0x8345530
The printed address 0x8345530 in this example is equal to the NSPersistentStoreCoordinator object released in the above code. The backtrace looks like this:
(gdb) bt
#0 0x0178be1e in ___forwarding___ ()
#1 0x0178bce2 in __forwarding_prep_0___ ()
#2 0x0122c75e in -[_NSSQLCoreConnectionObsever _purgeCaches:] ()
#3 0x00345a39 in __57-[NSNotificationCenter addObserver:selector:name:object:]_block_invoke_0 ()
#4 0x017f0885 in ___CFXNotificationPost_block_invoke_0 ()
#5 0x017f07a8 in _CFXNotificationPost ()
#6 0x0028a1aa in -[NSNotificationCenter postNotificationName:object:userInfo:] ()
#7 0x005e6169 in -[UIApplication _handleApplicationSuspend:eventInfo:] ()
#8 0x005ee8bd in -[UIApplication handleEvent:withNewEvent:] ()
#9 0x005ef1f8 in -[UIApplication sendEvent:] ()
#10 0x005e2aa9 in _UIApplicationHandleEvent ()
#11 0x01e45fa9 in PurpleEventCallback ()
#12 0x017f91c5 in __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ ()
#13 0x0175e022 in __CFRunLoopDoSource1 ()
#14 0x0175c90a in __CFRunLoopRun ()
#15 0x0175bdb4 in CFRunLoopRunSpecific ()
#16 0x0175bccb in CFRunLoopRunInMode ()
#17 0x01e44879 in GSEventRunModal ()
#18 0x01e4493e in GSEventRun ()
#19 0x005e0a9b in UIApplicationMain ()
#20 0x000046fd in main (argc=1, argv=0xbffff63c) at main.m:24
After a complete restart the app will of course work just fine again, with a plain new and empty storage file.
The above code is from my app delegate subclass, and the properties are declared like this:
#property (readonly, strong, nonatomic) NSManagedObjectContext *managedObjectContext;
#property (readonly, strong, nonatomic) NSPersistentStoreCoordinator *persistentStoreCoordinator;
#synthesize managedObjectContext = __managedObjectContext;
#synthesize persistentStoreCoordinator = __persistentStoreCoordinator;
What I just dont understand is, how can any object still use the OLD store coordinator instance when the retaincount obviously reached zero? I don't ever use/access this object outside of the app delegate class.
[edit] Just ran instruments (Zombie-mode), which yields similar results:
http://i41.tinypic.com/317ci91.jpg
As can be seen from the backtrace already, some purge-caches method is causing the crash. What is it, and how can I make it use the NEW store coordinator instance, and not the zombie one?
have you tried [self saveContext]; and place it in applicationWillTerminate: before the app has terminated. And you shouldn't use retainCount to see if an object is overreleased or overretain. You should user instrument instead

Unable to reload TableView Data in iOS App

I find my self out of ideas trying to get this app to work. My app uses a split view to show to lists. the "Master" list should hold a list of the user's Facebook friends. Since the app does not force you to login, if you're not logged in yet it shows "You have no friends" in the list till you've logged in. My problem is that once I've loaded all the friends and call [self.tableView reloadData] my program crashes some in there, and despite my best attempts at debugging it I can't find it. The method is
- (void)request:(FBRequest *)request didLoad:(id)result
{
if ([result isKindOfClass:[NSArray class]] && ([result count] > 0)) {
result = [result objectAtIndex:0];
}
switch (((Facebook *)[Facebook shared]).currentCall) {
case graphUserFriends:
{
_friends = [NSMutableArray array];
NSArray *resultData = [result objectForKey:#"data"];
if ([resultData count] > 0)
{
for (NSUInteger i=0; i<[resultData count] && i < 25; i++)
{
NSDictionary *friendDictionary = [resultData objectAtIndex:i];
FbFriend * f = [[[FbFriend alloc] initWithName:[friendDictionary objectForKey:#"name"] Id:[friendDictionary objectForKey:#"id"]] autorelease];
[_friends addObject:f];
}
}
[self.tableView reloadData];
break;
}
default:
break;
}
}
The whole source code (and Xcode 4 project) can be downloaded from https://skydrive.live.com/redir.aspx?cid=04b38cdd7b38bb7f&resid=4B38CDD7B38BB7F!798&parid=4B38CDD7B38BB7F!470&authkey=!API4iVva95nZFL8
Console (At Crash):
GNU gdb 6.3.50-20050815 (Apple version gdb-1708) (Mon Aug 15 16:03:10 UTC 2011)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "x86_64-apple-darwin".sharedlibrary apply-load-rules all
Attaching to process 48870.
Catchpoint 3 (throw)Pending breakpoint 1 - "objc_exception_throw" resolved
Current language: auto; currently objective-c
(gdb) bt
#0 0x0156ecf0 in objc_exception_throw ()
#1 0x013c9674 in -[__NSArrayI objectAtIndex:] ()
#2 0x00454805 in -[UITableViewDataSource tableView:heightForRowAtIndexPath:] ()
#3 0x0026427a in -[UITableViewController tableView:heightForRowAtIndexPath:] ()
#4 0x0020f548 in -[UISectionRowData refreshWithSection:tableView:tableViewRowData:] ()
#5 0x00211722 in -[UITableViewRowData numberOfRows] ()
#6 0x000c17c7 in -[UITableView noteNumberOfRowsChanged] ()
#7 0x000c12c1 in -[UITableView reloadData] ()
#8 0x0000247e in -[MasterViewController request:didLoad:] (self=0x6a491e0, _cmd=0x12e65, request=0x681e930, result=0x6824250) at /Users/CheckM8/Documents/Xcode 4/Projects/iPeople4/iPeople4/MasterViewController.m:46
#9 0x00009d36 in -[FBRequest handleResponseData:] (self=0x681e930, _cmd=0x1397a, data=0x6a76c60) at /Users/CheckM8/Documents/Xcode 4/facebook-facebook-ios-sdk-74358cd/src/FBRequest.m:261
#10 0x0000a357 in -[FBRequest connectionDidFinishLoading:] (self=0x681e930, _cmd=0xade62e, connection=0x681ec40) at /Users/CheckM8/Documents/Xcode 4/facebook-facebook-ios-sdk-74358cd/src/FBRequest.m:346
#11 0x00a29a59 in ___NSURLConnectionDidFinishLoading_block_invoke_0 ()
#12 0x00a27e94 in __65-[NSURLConnectionInternal _withConnectionAndDelegate:onlyActive:]_block_invoke_0 ()
#13 0x00a28eb7 in -[NSURLConnectionInternalConnection invokeForDelegate:] ()
#14 0x00a27e4f in -[NSURLConnectionInternal _withConnectionAndDelegate:onlyActive:] ()
#15 0x00a27fd5 in -[NSURLConnectionInternal _withActiveConnectionAndDelegate:] ()
#16 0x0096cf6a in _NSURLConnectionDidFinishLoading ()
#17 0x0398fbbd in URLConnectionClient::_clientDidFinishLoading ()
#18 0x03a5c5ea in URLConnectionClient::ClientConnectionEventQueue::processAllEventsAndConsumePayload ()
#19 0x03986298 in URLConnectionClient::processEvents ()
#20 0x03a5c16b in non-virtual thunk to URLConnectionInstanceData::multiplexerClientPerform() ()
#21 0x03986137 in MultiplexerSource::perform ()
#22 0x013b197f in __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ ()
#23 0x01314b73 in __CFRunLoopDoSources0 ()
#24 0x01314454 in __CFRunLoopRun ()
#25 0x01313db4 in CFRunLoopRunSpecific ()
#26 0x01313ccb in CFRunLoopRunInMode ()
#27 0x012c6879 in GSEventRunModal ()
#28 0x012c693e in GSEventRun ()
#29 0x00034a9b in UIApplicationMain ()
#30 0x00001d82 in main (argc=1, argv=0xbfffed64) at /Users/CheckM8/Documents/Xcode 4/Projects/iPeople4/iPeople4/main.m:16
#31 0x00001cf5 in start ()
You've made the classic memory management mistake: You're directly accessing your ivars and it burned you.
_friends = [NSMutableArray array];
This is an under-retain (which will crash later), and also a possible leak if _friends had a prior value. You should always use accessors for your ivars except in dealloc and init:
self.friends = [NSMutableArray array];
...
[self.friends addObject:f];
EDIT: From your stacktrace, your bug is in your table view data source's tableView:heightForRowAtIndexPath:. It looks like you're reading off the end of your array.

Resources