A class of service has a nonatomic property which is set in a serial queue.
@interface Service
@property (strong, nonatomic) NSDictionary *status;
@property (nonatomic) dispatch_queue_t queue;
...
@end
- (void)update:(NSDicationary *)paramDict {
dispatch_async(self.queue, ^{
....
self.status = updateDict;
}
}
- (void)someMethod {
NSDictionary *status = self.status;
}
The app crashed when the getter was invoked, at objc_autorelease + 6
, which seems to be a runtime/Clang/llvm invocation.
And the crash log also showed that the status
property was just set on the queue
thread.
Did it crash because of the lack of atomicity in the accessors? If yes, how and why the getter failed retaining the instance? Did the autorelease pool get drained inside the synthesized nonatomic setter?
Should I implement the getter/setter method, protecting it with queue
/a mutex lock?