RickJansen
RickJansen

Reputation: 1713

Crash with preferences (NSUserDefaults)?

I'm having this crash now and then, in a thread that is not started by me that I know, with CFXPreferencesPropertyListSourceSynchronizer and CFXPreferencesPropertyListSource mentioned. I do have a separate thread that accesses the NSUserDefaults. (NSUserDefaults is supposed to be thread safe.) Anyone recognize what is going wrong here?

Exception Type:  EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x444e4128
Crashed Thread:  5

Thread 5 name:  Dispatch queue: CFPreferences Background Sync Queue
Thread 5 Crashed:
0   libobjc.A.dylib                 0x34ec4f78 objc_msgSend + 16
1   CoreFoundation                  0x3710de90 CFRetain + 76
2   CoreFoundation                  0x3718aa96 __CFDictionaryStandardRetainValue + 62
3   CoreFoundation                  0x37114fe0 CFBasicHashCreateCopy + 832
4   CoreFoundation                  0x37124f50 CFDictionaryCreateMutableCopy + 388
5   CoreFoundation                  0x3712d340 -[CFXPreferencesPropertyListSourceSynchronizer initWithPropertyListSource:forLockedSynchronize:] + 232
6   CoreFoundation                  0x371b4800 __79-[CFXPreferencesPropertyListSource synchronizeInBackgroundWithCompletionBlock:]_block_invoke_0 + 56
7   libdispatch.dylib               0x302e5c52 _dispatch_call_block_and_release + 6
8   libdispatch.dylib               0x302f0ca4 _dispatch_queue_drain + 268
9   libdispatch.dylib               0x302f0b12 _dispatch_queue_invoke$VARIANT$up + 30
10  libdispatch.dylib               0x302f1784 _dispatch_worker_thread2 + 208
11  libsystem_c.dylib               0x33a34df4 _pthread_wqthread + 288
12  libsystem_c.dylib               0x33a34cc8 start_wqthread + 0

Upvotes: 1

Views: 1636

Answers (2)

RickJansen
RickJansen

Reputation: 1713

My fault indeed, I failed to properly retain a self.string object in a property setter.

Which object it concerned was not easy to find. The debugger and zombie objects were helpful to tell that indeed there was a released object that was referred, but I was unable to find out with the debugger what the object was that the hex address referred to. Not with gdb, nor with lldb. "po" told me "0x... does not appear to point to a valid object".

In the end I found out which object this concerned by printing out it's address in hex:

NSLog( @"self.text=%@ self.text=(%p)", self.text,self.text);

and seeing that address in the log and error message.

Upvotes: 0

tia
tia

Reputation: 9698

It crashes on CFRetain so my best guess is that you have over-released some key or some value, or you used non-object as key or value.

Upvotes: 1

Related Questions