0

I am getting an error on the Xcode console when running the following code:

// Create session
NSURLSession *session = [NSURLSession sessionWithConfiguration:[NSURLSessionConfiguration ephemeralSessionConfiguration]];

// Create request
NSURL *url = [NSURL URLWithString:@"https://my.backend.com/endpoint"];
NSMutableURLRequest *mutableRequest = [NSMutableURLRequest requestWithURL:url];
    mutableRequest.HTTPMethod = @"POST";
[mutableRequest setValue:@"text/plain" forHTTPHeaderField:@"Content-Type"];
NSData *postBody = [@"my_string_payload" dataUsingEncoding:NSUTF8StringEncoding];
[mutableRequest setHTTPBody:postBody];

// Create and initiate task 
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:mutableRequest];
[dataTask resume];

The error I get is following:

... [Common] _BSMachError: port c11b; (os/kern) invalid capability (0x14) "Unable to insert COPY_SEND"
... [Common] _BSMachError: port c11b; (os/kern) invalid name (0xf) "Unable to deallocate send right"

The error is shown when running the resume method. Everything seems to work fine though, there is no crash and the request works as expected.

I have looked for this error message and it is usually found related to 1) strange Xcode problems (such as this) or 2) UI elements lifecycle (such as here). These don't seem to apply to this case though.

I am using Xcode 8.3.3.

atineoSE
  • 3,597
  • 4
  • 27
  • 31
  • Just out of interest, why aren't you using NSURLSession block? – Supertecnoboff Jun 28 '17 at 10:20
  • @Supertecnoboff do you mean the completion handler for NSURLSessionDataTask? In the real code, I am using it, but for the sake of the question, I narrowed down the example to a more simple version that still exhibited the problem. – atineoSE Jun 28 '17 at 11:39

1 Answers1

0

I have just realized that the error only appears when running with breakpoints. When I run this section without breakpoints, the request still works as expected and there is no error in the console, so it looks like this is only an issue when debugging the NSURLSessionDataTask with breakpoints.

atineoSE
  • 3,597
  • 4
  • 27
  • 31