Core Data save exception - iphone

I got very weird issue with managedObjectContext:save. It hasn't happened at the first time I save the context, it only happens at some point of my program. Could you help me to know why it happened and where should I should find a bug in my code? Thanks.
Here is the log:
-[NSCFNumber UTF8String]: unrecognized selector sent to instance 0x5a64110
2011-05-19 16:02:43.235 DMC to Go[98212:40b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSCFNumber UTF8String]: unrecognized selector sent to instance 0x5a64110'
*** Call stack at first throw:
(
0 CoreFoundation 0x015d85a9 __exceptionPreprocess + 185
1 libobjc.A.dylib 0x0172c313 objc_exception_throw + 44
2 CoreFoundation 0x015da0bb -[NSObject(NSObject) doesNotRecognizeSelector:] + 187
3 CoreFoundation 0x01549966 ___forwarding___ + 966
4 CoreFoundation 0x01549522 _CF_forwarding_prep_0 + 50
5 CoreData 0x002f870f -[NSSQLiteConnection execute] + 1231
6 CoreData 0x0034aebd -[NSSQLiteConnection updateRow:] + 365
7 CoreData 0x00349e64 -[NSSQLConnection performAdapterOperations:] + 180
8 CoreData 0x00349b0e -[NSSQLCore _performChangesWithAdapterOps:] + 494
9 CoreData 0x003485ea -[NSSQLCore performChanges] + 410
10 CoreData 0x00342038 -[NSSQLCore saveChanges:] + 216
11 CoreData 0x00300199 -[NSSQLCore executeRequest:withContext:error:] + 409
12 CoreData 0x003b070b -[NSPersistentStoreCoordinator executeRequest:withContext:error:] + 3691
13 CoreData 0x00338948 -[NSManagedObjectContext save:] + 712
14 DMC to Go 0x0000313b -[dmcIpadAppDelegate saveManagedObjectChanges] + 107
15 DMC to Go 0x00020dc5 +[DmcIpadAppDelegate saveManagedObjectChanges] + 117
16 DMC to Go 0x00027883 -[DownloadFileService observeValueForKeyPath:ofObject:change:context:] + 867
17 Foundation 0x00fae1e4 NSKeyValueNotifyObserver + 361
18 Foundation 0x00fadca6 NSKeyValueDidChange + 384
19 Foundation 0x00f943e2 -[NSObject(NSKeyValueObserverNotification) didChangeValueForKey:] + 123
20 DMC to Go 0x0002c674 -[DownloadManager connectionDidFinishLoading:] + 836
21 Foundation 0x00fd4112 -[NSURLConnection(NSURLConnectionReallyInternal) sendDidFinishLoading] + 108
22 Foundation 0x00fd406b _NSURLConnectionDidFinishLoading + 133
23 CFNetwork 0x01dd948e _ZN19URLConnectionClient23_clientDidFinishLoadingEPNS_26ClientConnectionEventQueueE + 220
24 CFNetwork 0x01ea46e1 _ZN19URLConnectionClient26ClientConnectionEventQueue33processAllEventsAndConsumePayloadEP20XConnectionEventInfoI12XClientEvent18XClientEventParamsEl + 293
25 CFNetwork 0x01dcfc80 _ZN19URLConnectionClient13processEventsEv + 100
26 CFNetwork 0x01dcfacf _ZN17MultiplexerSource7performEv + 251
27 CoreFoundation 0x015b98ff __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
28 CoreFoundation 0x0151788b __CFRunLoopDoSources0 + 571
29 CoreFoundation 0x01516d86 __CFRunLoopRun + 470
30 CoreFoundation 0x01516840 CFRunLoopRunSpecific + 208
31 CoreFoundation 0x01516761 CFRunLoopRunInMode + 97
32 GraphicsServices 0x0202a1c4 GSEventRunModal + 217
33 GraphicsServices 0x0202a289 GSEventRun + 115
34 UIKit 0x00838c93 UIApplicationMain + 1160
35 DMC to Go 0x00001f59 main + 121
36 DMC to Go 0x00001ed5 start + 53
37 ??? 0x00000001 0x0 + 1
)
terminate called after throwing an instance of 'NSException'
Current language: auto; currently objective-c

Make sure you have no warnings
Put breakpoints in your code where you think you are setting an NSString on your object
And/Or NSLog %# the class of NSString properties of your core data objects and make sure it is some variation of an NSString. (NSLog(#"%#", [obj.property class]);)
What is happening is something that you are saving has an NSNumber object in place of an NSString. Since NSNumber does not respond to UTF8String your application is crashing.

Related

ios core data NSFetchedResultsControllerDelegate crash

I am keep getting this error for NSFetchedResultsControllerDelegate.
not sure what to do with it, since it happen sporadically.
I do create the records synchronized, but still ..
any ideas why could this be?
- (Activity *)createActivityWithDictionary:(NSDictionary*)dict
{
#synchronized([DBController sharedManaged])
{
Activity *act = [Activity activityWithDictionary:dict inManagedObjectContext:self.managedObjectContext];
[self saveContext];
return act;
}
}
Date/Time: 2012-09-18 22:55:53.686 -0700
OS Version: iPhone OS 5.1.1 (9B206)
Report Version: 104
Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x00000000, 0x00000000
Crashed Thread: 0
Last Exception Backtrace:
0 CoreFoundation 0x3724188f __exceptionPreprocess + 163
1 libobjc.A.dylib 0x34f46259 objc_exception_throw + 33
2 CoreFoundation 0x37244a9b -[NSObject doesNotRecognizeSelector:] + 175
3 CoreFoundation 0x37243915 ___forwarding___ + 301
4 CoreFoundation 0x3719e650 _CF_forwarding_prep_0 + 48
5 CoreData 0x36a78f4d -[NSFetchedResultsController(PrivateMethods) _managedObjectContextDidChange:] + 2401
6 Foundation 0x37aa64ff __57-[NSNotificationCenter addObserver:selector:name:object:]_block_invoke_0 + 19
7 CoreFoundation 0x3720d547 ___CFXNotificationPost_block_invoke_0 + 71
8 CoreFoundation 0x37199097 _CFXNotificationPost + 1407
9 Foundation 0x37a1a3eb -[NSNotificationCenter postNotificationName:object:userInfo:] + 67
10 CoreData 0x36a00839 -[NSManagedObjectContext(_NSInternalNotificationHandling) _postObjectsDidChangeNotificationWithUserInfo:] + 77
11 CoreData 0x36a0031d -[NSManagedObjectContext(_NSInternalChangeProcessing) _createAndPostChangeNotification:withDeletions:withUpdates:withRefreshes:] + 305
12 CoreData 0x36a09d01 -[NSManagedObjectContext(_NSInternalChangeProcessing) _processRecentChanges:] + 1245
13 CoreData 0x369fd145 -[NSManagedObjectContext save:] + 201
14 PalFinds 0x000a57cb -[DBController saveContext] (DBController.m:75)
15 PalFinds 0x000a8dff -[DBController createActivityWithDictionaries:] (DBController.m:852)
16 PalFinds 0x00086649 -[PFMe finishRequest:andRestConnection:] (PFMe.m:1986)
17 PalFinds 0x0002e17d -[RestConnection connectionDidFinishLoading:] (RestConnection.m:326)
18 Foundation 0x37addc29 __65-[NSURLConnectionInternal _withConnectionAndDelegate:onlyActive:]_block_invoke_0 + 17
19 Foundation 0x37a356d9 -[NSURLConnectionInternalConnection invokeForDelegate:] + 29
20 Foundation 0x37a356a3 -[NSURLConnectionInternal _withConnectionAndDelegate:onlyActive:] + 199
21 Foundation 0x37a355c5 -[NSURLConnectionInternal _withActiveConnectionAndDelegate:] + 61
22 CFNetwork 0x36ed97f5 URLConnectionClient::_clientDidFinishLoading(URLConnectionClient::ClientConnectionEventQueue*) + 193
23 CFNetwork 0x36ece4a5 URLConnectionClient::ClientConnectionEventQueue::processAllEventsAndConsumePayload(XConnectionEventInfo<XClientEvent, XClientEventParams>*, long) + 425
24 CFNetwork 0x36ece599 URLConnectionClient::ClientConnectionEventQueue::processAllEventsAndConsumePayload(XConnectionEventInfo<XClientEvent, XClientEventParams>*, long) + 669
25 CFNetwork 0x36ece599 URLConnectionClient::ClientConnectionEventQueue::processAllEventsAndConsumePayload(XConnectionEventInfo<XClientEvent, XClientEventParams>*, long) + 669
26 CFNetwork 0x36ece1a3 URLConnectionClient::processEvents() + 107
27 CFNetwork 0x36ece0d9 MultiplexerSource::perform() + 157
28 CoreFoundation 0x37215ad3 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
29 CoreFoundation 0x3721529f __CFRunLoopDoSources0 + 215
30 CoreFoundation 0x37214045 __CFRunLoopRun + 653
31 CoreFoundation 0x371974a5 CFRunLoopRunSpecific + 301
32 CoreFoundation 0x3719736d CFRunLoopRunInMode + 105
33 GraphicsServices 0x33956439 GSEventRunModal + 137
34 UIKit 0x30f43cd5 UIApplicationMain + 1081
35 PalFinds 0x000038bf main (main.mm:14)
36 PalFinds 0x00003878 start + 40
Looks like it's trying to call the delegate back and the delegate isn't implementing a method it's supposed to.
I'm thinking either controller:didChangeObject:atIndexPath:forChangeType:newIndexPath: or controllerDidChangeContent:
Did you implement those methods in your NSFetchedResultsControllerDelegate?
I know this might seem far fetched BUT I had a very similar problem and I had all those methods implemented and then I realized I had my release commented out for the fetchedREsultsController...once I put that back in no more sigbart and works like a charm.
All I'm saying is that sometimes the error isn't always the obvious.
We would need to see a bit more code to figure it out. Thanks.

App Crash While hitting web Services

I have a table view in which Iam selecting a row of the table view and then it hits the web services, retrieves data and then displayed. Now this is my error log Iam getting.
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-
[__NSCFData setDownloadedLogoImage:]: unrecognized selector sent to instance 0x806cf90'
*** Call stack at first throw:
(
0 CoreFoundation 0x02abdb99 __exceptionPreprocess + 185
1 libobjc.A.dylib 0x02c0d40e objc_exception_throw + 47
2 CoreFoundation 0x02abf6ab -[NSObject(NSObject) doesNotRecognizeSelector:] + 187
3 CoreFoundation 0x02a2f2b6 ___forwarding___ + 966
4 CoreFoundation 0x02a2ee72 _CF_forwarding_prep_0 + 50
5 FlightSearch 0x000401ef -[AirlineNames connectionDidFinishImage:] + 168
6 FlightSearch 0x0002f535 -[SAHttpManager connectionDidFinishLoading:] + 195
7 Foundation 0x001acb96 -[NSURLConnection(NSURLConnectionReallyInternal) sendDidFinishLoading] + 108
8 Foundation 0x001acaef _NSURLConnectionDidFinishLoading + 133
9 CFNetwork 0x0307172f _ZN19URLConnectionClient23_clientDidFinishLoadingEPNS_26ClientConnectionEventQueueE + 285
10 CFNetwork 0x0313cfcf _ZN19URLConnectionClient26ClientConnectionEventQueue33processAllEventsAndConsumePayloadEP20XConnectionEventInfoI12XClientEvent18XClientEventParamsEl + 389
11 CFNetwork 0x03066968 _ZN19URLConnectionClient13processEventsEv + 100
12 CFNetwork 0x030667e5 _ZN17MultiplexerSource7performEv + 251
13 CoreFoundation 0x02a9efaf __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
14 CoreFoundation 0x029fd39b __CFRunLoopDoSources0 + 571
15 CoreFoundation 0x029fc896 __CFRunLoopRun + 470
16 CoreFoundation 0x029fc350 CFRunLoopRunSpecific + 208
17 CoreFoundation 0x029fc271 CFRunLoopRunInMode + 97
18 GraphicsServices 0x032b000c GSEventRunModal + 217
19 GraphicsServices 0x032b00d1 GSEventRun + 115
20 UIKit 0x00419af2 UIApplicationMain + 1160
21 FlightSearch 0x00001e86 main + 84
22 FlightSearch 0x00001e29 start + 53
23 ??? 0x00000001 0x0 + 1
)
terminate called after throwing an instance of 'NSException'
Kindly suggest me what should i do.
You're sending the message setDownloadedLogoImage: to an NSData object, which has no idea what to do with it! One of two things has happened:
1) You have not retained something. Take a look at whatever object you expect to call setDownloadedLogoImage on and find out where you create it - you should probably be retaining it there ;)
2) (less likely) Your code is just wrong! Add it to your question and we can take a look.

Exception when running PhoneGap0.9.6 application on iPhone

We have an PhoneGap application that runs perfectly okay when using the simulator but once running this in the actual iPhone connected to mac we get an exception (errors below). Note the application was working perfectly fine before upgrade to PhoneGap0.9.6/
objc[356]: Class Connection is implemented in both /System/Library/PrivateFrameworks/Message.framework/Message and /var/mobile/Applications/D1D682A1-010B-4AE9-8761-4D553FCF8089/Frank151.app/Frank151. One of the two will be used. Which one is undefined.
[Switching to process 13059 thread 0x0]
2011-07-08 18:00:45.355 Frank151[356:707] -[Connection initWithWebView:]: unrecognized selector sent to instance 0x17e4e0
2011-07-08 18:00:45.378 Frank151[356:707] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[Connection initWithWebView:]: unrecognized selector sent to instance 0x17e4e0'
*** Call stack at first throw:
(
0 CoreFoundation 0x3166564f __exceptionPreprocess + 114
1 libobjc.A.dylib 0x35180c5d objc_exception_throw + 24
2 CoreFoundation 0x316691bf -[NSObject(NSObject) doesNotRecognizeSelector:] + 102
3 CoreFoundation 0x31668649 ___forwarding___ + 508
4 CoreFoundation 0x315df180 _CF_forwarding_prep_0 + 48
5 Frank151 0x00017469 -[PhoneGapDelegate getCommandInstance:] + 164
6 Frank151 0x00002f7f -[AppDelegate getCommandInstance:] + 62
7 Frank151 0x00016807 -[PhoneGapDelegate deviceProperties] + 234
8 Frank151 0x00016475 -[PhoneGapDelegate webViewDidFinishLoad:] + 28
9 Frank151 0x00003071 -[AppDelegate webViewDidFinishLoad:] + 212
10 UIKit 0x318a9061 -[UIWebView webView:didFinishLoadForFrame:] + 244
11 UIKit 0x318a8427 -[UIWebViewWebViewDelegate webView:didFinishLoadForFrame:] + 22
12 CoreFoundation 0x316687a4 __invoking___ + 68
13 CoreFoundation 0x315e043d -[NSInvocation invoke] + 108
14 CoreFoundation 0x315e00d9 -[NSInvocation invokeWithTarget:] + 36
15 WebKit 0x345887bd -[_WebSafeForwarder forwardInvocation:] + 408
16 CoreFoundation 0x3166868d ___forwarding___ + 576
17 CoreFoundation 0x315df180 _CF_forwarding_prep_0 + 48
18 CoreFoundation 0x316687a4 __invoking___ + 68
19 CoreFoundation 0x315e043d -[NSInvocation invoke] + 108
20 WebCore 0x36c39c3d _ZL11SendMessageP12NSInvocation + 16
21 WebCore 0x36cdcadf _ZL20HandleDelegateSourcePv + 66
22 CoreFoundation 0x3163ca79 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 12
23 CoreFoundation 0x3163e75f __CFRunLoopDoSources0 + 382
24 CoreFoundation 0x3163f4eb __CFRunLoopRun + 230
25 CoreFoundation 0x315cfec3 CFRunLoopRunSpecific + 230
26 CoreFoundation 0x315cfdcb CFRunLoopRunInMode + 58
27 GraphicsServices 0x30f4e41f GSEventRunModal + 114
28 GraphicsServices 0x30f4e4cb GSEventRun + 62
29 UIKit 0x316f5d69 -[UIApplication _run] + 404
30 UIKit 0x316f3807 UIApplicationMain + 670
31 Frank151 0x00002caf main + 78
32 Frank151 0x00002c5c start + 40
)
terminate called after throwing an instance of 'NSException'
[Switching to process 11779 thread 0x0]
(gdb)
UPDATE: After not much luck after trying many things we decided to downgrade the application to PG 0.9.5.1 and it worked with no issues. Not sure of the cause but something to do with PhoneGap 0.9.6 upgrade.
Start by disabling any plug ins......
webView may be referring to ChildBrowser Plugin.

exception while trying to save CoreData

NSError *error;
if (managedObjectContext != nil) {
if ([managedObjectContext hasChanges] && ![managedObjectContext save:&error]) {
DLog(#"Unresolved error %#, %#", error, [error userInfo]);
abort();
}
}
while saving some items with the above code in CoreDate i get the following exception. the managedObjectContext has 50 unresolved deletes and 700 unresolved insertions. obviously its having a problem with the deletes. any ideas on how to track it down?
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSSet0 removeObject:]: unrecognized selector sent to instance 0x61a4840'
*** Call stack at first throw:
(
0 CoreFoundation 0x018d45a9 __exceptionPreprocess + 185
1 libobjc.A.dylib 0x01a28313 objc_exception_throw + 44
2 CoreFoundation 0x018d60bb -[NSObject(NSObject) doesNotRecognizeSelector:] + 187
3 CoreFoundation 0x01845966 ___forwarding___ + 966
4 CoreFoundation 0x01845522 _CF_forwarding_prep_0 + 50
5 CoreData 0x00ffa31d -[NSManagedObject(_NSInternalMethods) _excludeObject:fromPropertyWithKey:andIndex:] + 397
6 CoreData 0x00fef7d1 -[NSManagedObject(_NSInternalMethods) _maintainInverseRelationship:forProperty:oldDestination:newDestination:] + 449
7 CoreData 0x01043b55 -[NSManagedObject(_NSInternalMethods) _propagateDelete:] + 1541
8 CoreData 0x00ffa02a -[NSManagedObject(_NSInternalMethods) _propagateDelete] + 42
9 CoreData 0x00ff9e53 -[NSManagedObjectContext(_NSInternalChangeProcessing) _propagateDeletesUsingTable:] + 515
10 CoreData 0x00ff9c12 -[NSManagedObjectContext(_NSInternalChangeProcessing) _processDeletedObjects:] + 146
11 CoreData 0x00fecba8 -[NSManagedObjectContext(_NSInternalChangeProcessing) _propagatePendingDeletesAtEndOfEvent:] + 104
12 CoreData 0x00fb8982 -[NSManagedObjectContext(_NSInternalChangeProcessing) _processRecentChanges:] + 754
13 CoreData 0x00ff2715 -[NSManagedObjectContext save:] + 149
14 Ace Metrix iPad 0x00075153 +[CoreDataHelper saveCoreDate:] + 82
15 Ace Metrix iPad 0x0007a790 -[WSBreakingAds platformRequestFinishedWhidType:withResponse:] + 772
16 Ace Metrix iPad 0x00077c6d -[PlatformContainer operation:completedWithResponse:withNSManagedObjectContext:] + 1042
17 Ace Metrix iPad 0x000401ec -[WebServiceAuthServiceSoapBinding_getPartialAdvertisementsAfterDate connectionDidFinishLoading:] + 1209
18 Foundation 0x00182112 -[NSURLConnection(NSURLConnectionReallyInternal) sendDidFinishLoading] + 108
19 Foundation 0x0018206b _NSURLConnectionDidFinishLoading + 133
20 CFNetwork 0x00dec492 _ZN19URLConnectionClient23_clientDidFinishLoadingEPNS_26ClientConnectionEventQueueE + 220
21 CFNetwork 0x00eb76e1 _ZN19URLConnectionClient26ClientConnectionEventQueue33processAllEventsAndConsumePayloadEP20XConnectionEventInfoI12XClientEvent18XClientEventParamsEl + 293
22 CFNetwork 0x00de2c84 _ZN19URLConnectionClient13processEventsEv + 100
23 CFNetwork 0x00de2ad3 _ZN17MultiplexerSource7performEv + 251
24 CoreFoundation 0x018b58ff __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
25 CoreFoundation 0x0181388b __CFRunLoopDoSources0 + 571
26 CoreFoundation 0x01812d86 __CFRunLoopRun + 470
27 CoreFoundation 0x01812840 CFRunLoopRunSpecific + 208
28 CoreFoundation 0x01812761 CFRunLoopRunInMode + 97
29 GraphicsServices 0x01e3e1c4 GSEventRunModal + 217
30 GraphicsServices 0x01e3e289 GSEventRun + 115
31 UIKit 0x003eec93 UIApplicationMain + 1160
32 Ace Metrix iPad 0x00002814 main + 102
33 Ace Metrix iPad 0x000027a5 start + 53
)
terminate called after throwing an instance of 'NSException'
You are calling removeObject: on an immutable instance of NSSet. Make sure that the set you work with is an instance of NSMutableSet. It might help us if you could post the code where you actually perform the deletes.

Getting strange intermittent "unrecognized selector" exceptions in iPhone app

Recently, I've been getting intermittent error reports from my app claiming "unrecognized selector" in areas that could not possibly cause them, and yet they do.
For example, this one:
Error: NSInvalidArgumentException: *** -[NSCFString didReceiveMemoryWarning]: unrecognized selector sent to instance 0x541fe0
0 CoreFoundation 0x32de1e23 __handleUncaughtException + 230
1 libobjc.A.dylib 0x3266d894 _objc_terminate + 156
2 libstdc++.6.dylib 0x338c3a8c _ZN10__cxxabiv111__terminateEPFvvE + 84
3 libstdc++.6.dylib 0x338c3b04 _ZSt9terminatev + 24
4 libstdc++.6.dylib 0x338c3c2c __cxa_throw + 108
5 libobjc.A.dylib 0x3266be5c objc_exception_throw + 112
6 CoreFoundation 0x32de2bfd -[NSObject doesNotRecognizeSelector:] + 112
7 CoreFoundation 0x32d67b19 ___forwarding___ + 480
8 CoreFoundation 0x32d5e840 _CF_forwarding_prep_0 + 48
9 Foundation 0x33f765d9 _nsnote_callback + 184
10 CoreFoundation 0x32d9e511 _CFXNotificationPostNotification + 304
11 Foundation 0x33f741b3 -[NSNotificationCenter postNotificationName:object:userInfo:] + 70
12 Foundation 0x33f76519 -[NSNotificationCenter postNotificationName:object:] + 20
13 UIKit 0x30d18db8 -[UIApplication _performMemoryWarning] + 68
14 UIKit 0x30d18d50 -[UIApplication _receivedMemoryNotification] + 136
15 UIKit 0x30d18c80 _memoryStatusChanged + 64
16 CoreFoundation 0x32d66eb7 __CFNotificationCenterDarwinCallBack + 26
17 CoreFoundation 0x32d5cb51 __CFMachPortPerform + 78
18 CoreFoundation 0x32da452b CFRunLoopRunSpecific + 2302
19 CoreFoundation 0x32da3c1f CFRunLoopRunInMode + 50
20 GraphicsServices 0x31bb9374 GSEventRunModal + 196
21 UIKit 0x30bf3c30 -[UIApplication _run] + 560
22 UIKit 0x30bf2230 UIApplicationMain + 968
23 Mind 0x00002c68 main + 72
24 Mind 0x00002be4 start + 52
This is the OS sending a memory warning to my app, and somehow the application class has changed into a string.
It seems to happen a lot more when the code is invoked via an NSOperation:
Error: NSInvalidArgumentException: -[NSCFString setObject:forKey:]: unrecognized selector sent to instance 0x3e793088
9 Mind 0x0015de70 -[CCTextureCache textureFromFile:] + 528
10 Mind 0x0015d9f4 -[CCTextureCache loadImageUncached:pixelFormat:] + 116
11 Mind 0x0015d058 -[CCTextureCache addImage:pixelFormat:] + 152
12 Mind 0x00080524 -[ImageLoader imageWithFile:pixelFormat:] + 84
13 Mind 0x000854c4 -[ImageLoadOperation performLoad] + 68
14 Mind 0x00085800 -[ResourceLoadOperation main] + 112
15 Foundation 0x30c4c8b5 -[__NSOperationInternal start] + 664
16 Foundation 0x30c4c613 -[NSOperation start] + 22
17 Foundation 0x30cbdb63 ____startOperations_block_invoke_2 + 46
18 libSystem.B.dylib 0x31227858 _dispatch_call_block_and_release + 20
19 libSystem.B.dylib 0x3122863c _dispatch_worker_thread2 + 128
20 libSystem.B.dylib 0x311b1544 _pthread_wqthread + 400
21 libSystem.B.dylib 0x311a8b74 __stack_chk_fail + 4294967295
The code in question is:
[textures setObject:texture forKey:filename];
textures is type NSMutableDictionary* and never gets reassigned or deallocated (naturally, since this is a cache object). This is the only place where setObject is invoked in this method, yet according to the stack trace, textures was a string.
I also get this weirdness:
Error: NSInvalidArgumentException: -[NSConcreteNotification getPixelFormatForIdentifier:]: unrecognized selector sent to instance 0x5c021b0
9 Mind 0x0015dd0c -[CCTextureCache textureFromFile:] + 172
10 Mind 0x0015d9f4 -[CCTextureCache loadImageUncached:pixelFormat:] + 116
11 Mind 0x0015d058 -[CCTextureCache addImage:pixelFormat:] + 152
12 Mind 0x00080524 -[ImageLoader imageWithFile:pixelFormat:] + 84
13 Mind 0x000854c4 -[ImageLoadOperation performLoad] + 68
14 Mind 0x00085800 -[ResourceLoadOperation main] + 112
15 Foundation 0x347b78b5 -[__NSOperationInternal start] + 664
16 Foundation 0x347b7613 -[NSOperation start] + 22
17 Foundation 0x34828b63 ____startOperations_block_invoke_2 + 46
18 libSystem.B.dylib 0x32a2f858 _dispatch_call_block_and_release + 20
19 libSystem.B.dylib 0x32a3063c _dispatch_worker_thread2 + 128
20 libSystem.B.dylib 0x329b9544 _pthread_wqthread + 400
21 libSystem.B.dylib 0x329b0b74 __stack_chk_fail + 4294967295
This trace is from the following code in CCTextureCache:
CCTexture2DPixelFormat pixelFormat = [self getPixelFormatForIdentifier:identifier];
How CCTextureCache changed into NSConcreteNotification after having already called a number of methods on itself is baffling to say the least.
Has anyone else noticed this sort of thing? Am I somehow getting memory corruption?
Did you check some race conditions about multi-threads ? It seems like some resource freed by another thread, and current thread send a messaged to a deallocated object.
Error: NSInvalidArgumentException: -[NSCFString setObject:forKey:]: unrecognized selector sent to instance 0x3e793088
9 Mind 0x0015de70 -[CCTextureCache textureFromFile:] + 528
10 Mind 0x0015d9f4 -[CCTextureCache loadImageUncached:pixelFormat:] + 116
11 Mind 0x0015d058 -[CCTextureCache addImage:pixelFormat:] + 152
12 Mind 0x00080524 -[ImageLoader imageWithFile:pixelFormat:] + 84
13 Mind 0x000854c4 -[ImageLoadOperation performLoad] + 68
14 Mind 0x00085800 -[ResourceLoadOperation main] + 112
15 Foundation 0x30c4c8b5 -[__NSOperationInternal start] + 664
16 Foundation 0x30c4c613 -[NSOperation start] + 22
17 Foundation 0x30cbdb63 ____startOperations_block_invoke_2 + 46
18 libSystem.B.dylib 0x31227858 _dispatch_call_block_and_release + 20
19 libSystem.B.dylib 0x3122863c _dispatch_worker_thread2 + 128
20 libSystem.B.dylib 0x311b1544 _pthread_wqthread + 400
21 libSystem.B.dylib 0x311a8b74 __stack_chk_fail + 4294967295
This is often caused by memory management errors. Did you try zombies?
...with zombies enabled, messages to deallocated objects will no longer behave
strangely or crash in difficult-to-understand ways, but will instead log a message
and die in a predictable and debugger-breakpointable way. This is the tool to use
when trying to track down over-releases and premature releases.
I just ran into the same problem, but it turns out I had made a stupid mistake:
I had declared a member like this in the header file:
NSMutableDictionary* myDict;
But then initialized it like this in the .m file:
myDict = [[NSDictionary alloc] init];
which is valid and all, because the NSMutableDictionary is derived from the NSDictionary class. Therefore all calls that are inherited from NSDictionary actually worked, but the calls specific to NSMutableDictionary [setObject: forKey:] failed because I tried to invoke them on the parent class.
The mistake was really dumb, but I was also thrown off by the fact that the debugger reported the type of myDict as something totally different (neither NSDictionary, nor NSMutableDictionary). I hope this helps some other tired coder :-)