{"action":"opened","issue":{"url":"https://api.github.com/repos/facebook/react-native/issues/5011","labels_url":"https://api.github.com/repos/facebook/react-native/issues/5011/labels{/name}","comments_url":"https://api.github.com/repos/facebook/react-native/issues/5011/comments","events_url":"https://api.github.com/repos/facebook/react-native/issues/5011/events","html_url":"https://github.com/facebook/react-native/issues/5011","id":124132847,"number":5011,"title":"Crash in [RCTModuleMethod invokeWithBridge:module:arguments:] when using DISPATCH_QUEUE_CONCURRENT","user":{"login":"philikon","id":54918,"avatar_url":"https://avatars.githubusercontent.com/u/54918?v=3","gravatar_id":"","url":"https://api.github.com/users/philikon","html_url":"https://github.com/philikon","followers_url":"https://api.github.com/users/philikon/followers","following_url":"https://api.github.com/users/philikon/following{/other_user}","gists_url":"https://api.github.com/users/philikon/gists{/gist_id}","starred_url":"https://api.github.com/users/philikon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/philikon/subscriptions","organizations_url":"https://api.github.com/users/philikon/orgs","repos_url":"https://api.github.com/users/philikon/repos","events_url":"https://api.github.com/users/philikon/events{/privacy}","received_events_url":"https://api.github.com/users/philikon/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-12-28T22:05:08Z","updated_at":"2015-12-28T22:05:08Z","closed_at":null,"body":"Consider an iOS native module definition:\r\n```objc\r\n#import \"RCTBridgeModule.h\"\r\n\r\n@interface RCT_EXTERN_REMAP_MODULE(Foobar, Foobar, NSObject)\r\nRCT_EXTERN_METHOD(getFoobars:(nonnull NSNumber *)howMany callback:(RCTResponseSenderBlock *)callback)\r\n@end\r\n```\r\n\r\nand an accompanying Swift implementation:\r\n\r\n```swift\r\n@objc(Foobar)\r\npublic class Foobar : NSObject {\r\n\r\n  static let QUEUE = dispatch_queue_create(\"com.foobar.foobar\", DISPATCH_QUEUE_CONCURRENT)\r\n  var methodQueue: dispatch_queue_t {\r\n    return Foobar.QUEUE;\r\n  }\r\n\r\n  public func getFoobars(howMany: NSNumber, callback: RCTResponseSenderBlock) {\r\n    ...\r\n  }\r\n}\r\n```\r\n\r\nThis setup worked fine in React Native 0.15. But since the upgrade to React Native 0.17 (I leap-frogged 0.16), it crashes randomly in `[RCTModuleMethod invokeWithBridge:module:arguments:]` with `EXC_BAD_ACCESS` at https://github.com/facebook/react-native/blob/v0.17.0/React/Base/RCTModuleMethod.m#L470 in Thread 18 (com.foobar.foobar).\r\n\r\n```\r\n(lldb) po _invocation\r\n<NSInvocation: 0x165c68b0>\r\nreturn value: {v} void\r\ntarget: {@} 0x1653fc90\r\nselector: {:} getFoobars:callback:\r\nargument 2: {@} 0x178bcd90\r\nargument 3: {@?} 0x165f6ca0 (block)\r\n\r\n(lldb) po index\r\n3\r\n```\r\nSo it's trying to release the callback argument, but failing -- likely because it's already been released.\r\n\r\nMaking the module's queue not a concurrent queue, but a serial one (`DISPATCH_QUEUE_SERIAL` or simply `nil`) seems to make the problem go away.\r\n\r\nIt seems reasonable to me if React required native modules to only use serial queues, though perhaps that should be documented then. Or perhaps the release mechanism introduced in 71da2917e577b7ec659083408cff7f9981d6600f needs some tweaking so it can work with concurrent queues? cc @tadeuzagallo "}}