Open RetVal opened 8 years ago
We are seeing a bug where multiple background thread activities are causing a crash with the stack trace as seen below. Can we get someone to talk about this fix for the ones that involve the [BSSinglton scope:]
call? With regards to inFlightKeys
I am wondering if it's related to the Thread specific dictionary. Let me know what you think.
the BSSingleton scope, because BSSingleton's source is nonatomic, [scope scope:provider] will try to use the source of BSSingleton, step is
But in the multi-thread environment, [singleton scope:] will set the singleton's source property, [singleton provide:injector:] will reset the source to nil if instance is nil, and the source property is not marked as atomic, so getter and setter will case the multi-thread problem.
dispatch_apply(1000, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^(size_t idx) { [inject getInstance:[TestClass class]]; // which bind to BSSingleton scope, because BSSingleton's source is nonatomic, will crash inside [scope scope:provider], the BSSingleton BSScope protocol implement. });