title: objective c gets EXC_BAD_ACCESS error on completionhandler
body: <p>i'm new to objective-c, please bear with me if i ask stupid questions :) 
  The following is part of code i have to start vpn tunnel, but keeps getting EXC_BAD_ACCESS error</p>
  
  <pre><code>- (void)startTunnelWithOptions:(NSDictionary *)options completionHandler:(void (^)(BOOL * error))completionHandler {
  
      vpnAdapter = [[OpenAdapter alloc] init];
      vpnAdapter.delegate = self;
  
      // get config
  
      config = [[NSDictionary alloc] init];
  
      NETunnelProviderProtocol *protocol = (NETunnelProviderProtocol *)self.protocolConfiguration;
      config = protocol.providerConfiguration;
  
      host = config[@"server"];
  
      // Load config data
      username = config[@"username"];
      password = config[@"password"];
  
  
      if(option != nil){
          [vpnAdapter connect:host user:username pass:password add:YES completionHandler:^(BOOL success){
             // return success;
              completionHandler(&amp;success); // Thread 2: EXC_BAD_ACCESS (code=1, address=0xbcc68f020)
          }];
  
      }else{
          [vpnAdapter connect:host user:username pass:password add:NO completionHandler:^(BOOL success){
  
              completionHandler(&amp;success);
  
          }];
      } 
  }
  </code></pre>
  
  <p>here is connect method </p>
  
  <pre><code>- (void)connect: (NSString *) host user:(NSString *)username pass:(NSString *) password add:(Boolean) isAdd completionHandler:(void (^)(BOOL success)) completionHandler{
  
      dispatch_queue_attr_t attributes = dispatch_queue_attr_make_with_qos_class(DISPATCH_QUEUE_SERIAL, QOS_CLASS_UTILITY, 0);
      dispatch_queue_t connectQueue = dispatch_queue_create("me.ss-abramchuk.open-adapter.connection", attributes);
      dispatch_async(connectQueue, ^{
          // Call connect
          //int ret=1;
          NSArray* options = [NSArray arrayWithObjects:
                              @"--user", username,
                              host,
                              nil];
  
          if(isAdd){
              options = [NSArray arrayWithObjects:
                         @"--user", username,
                         @"--protocol", @"ad",
                         host,
                         nil];
          }
          //NSArray *paths = NSSearchPathForDirectoriesInDomains
          (NSDocumentDirectory, NSUserDomainMask, YES);
          //NSString *documentsDirectory = [paths objectAtIndex:0];
  
          NSMutableArray *arguments = [NSMutableArray arrayWithCapacity:1+[options count]];
          [arguments addObject:@"connect"];
          [arguments addObjectsFromArray:options];
  
          int argc = [arguments count];
          char **argv = (char **)malloc(sizeof(char*) * (argc + 1));
  
          [arguments enumerateObjectsUsingBlock:^(NSString *option, NSUInteger i, BOOL *stop) {
              const char * c_string = [option UTF8String];
              int length = (int)strlen(c_string);
              char *c_string_copy = (char *) malloc(sizeof(char) * (length + 1));
              strcpy(c_string_copy, c_string);
              argv[i] = c_string_copy;
          }];
          argv[argc] = NULL;
          const char *cfPass=[password UTF8String];
          int ret = self.vpnClient-&gt;start2connect(argc, argv, cfPass);
          BOOL result;
          if (ret!=0){
              result=false;
          }
          else {result = true;}
          completionHandler(result);
      }); 
  }
  </code></pre>
  
  <p>all of these are from networkextension and while debugging, i found <code>int ret = self.vpnClient-&gt;start2connect(argc, argv, cfPass);</code>
  seems not returning any value.</p>
  
  <p>however, i confirmed that the <strong><em>start2connect</em></strong> method does return int value 
  so for now, anyone can help explain what's wrong?</p>
  
  <p>thanks</p>