From bc1a1b4411aa6e6e955a95f9219a9afb009274e6 Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Tue, 17 Apr 2018 14:39:25 -0700 Subject: [PATCH] Comment on the fix --- src/objective-c/GRPCClient/private/GRPCHost.m | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/objective-c/GRPCClient/private/GRPCHost.m b/src/objective-c/GRPCClient/private/GRPCHost.m index 07cfe1329b0..bfb1fd352c5 100644 --- a/src/objective-c/GRPCClient/private/GRPCHost.m +++ b/src/objective-c/GRPCClient/private/GRPCHost.m @@ -108,6 +108,9 @@ static NSMutableDictionary *kHostCache; serverName:(NSString *)serverName timeout:(NSTimeInterval)timeout completionQueue:(GRPCCompletionQueue *)queue { + // The __block attribute is to allow channel take refcount inside @synchronized block. Without + // this attribute, retain of channel object happens after objc_sync_exit in release builds, which + // may result in channel released before used. See grpc/#15033. __block GRPCChannel *channel; // This is racing -[GRPCHost disconnect]. @synchronized(self) {