Unable to use Leaks in Instruments

I have a Mac app and when I want to profile it for leaks, I get an error "Unable to acquire required task port" from Instruments. I can't really find anyone else with this issue on the web, but it must be something to do with my application because I see the same thing on both Xcode 9.3 on High Sierra, and Xcode 10 on the first Mojave developer preview, each on separate Macs.


Any suggestions? 🙂

Accepted Reply

Aha! It's definitely some kind of signing issue. We are signing with a Developer ID, because the app is distributed outside the MAS, but if I disable signing, I'm able to run the Leaks profile.


Unfortunately, this is all complicated by us doing our signing in a Build Phases script (so fresh github checkouts by people other than me, can build immediately). Hopefully I can find an environment variable that will let me skip signing if the build is for Instruments!


Thanks very much for your replies 🙂

Replies

Are you trying to profile an app that's installed or on that you're building via Xcode?

I'm also having the same issue as @cmsj, when trying to profile an app that's being built via Xcode.


The app in question is Hammerspoon - you can download the source code here: http://www.hammerspoon.org
I'm running macOS 10.13.5 on a MacBook Pro (15-inch, 2017) with Xcode 9.4.1.

The error I get is:
An error occurred trying to capture Leaks data.
Unable to acquire required task port (7824:0)


Any ideas @cwoolf?

Building in Xcode. The app is opensource if someone wants to try and reproduce the failure - https://github.com/Hammerspoon/hammerspoon

(I think my reply got moderated for having a URL in it)


I'm building the app in Xcode using Product->Profile.


If it helps, the app is open source. It lives on GitHub in Hammerspoon/hammerspoon (note that to build it you need to pip install -r requirements.txt for something the docs need)

It's been a while since I had to troubleshoot a problem like this, but you might want to check that:

1.) Your provisioning profile is installed on the device, and it matches with app ID you're trying to profile.

2.) Your "Release" configuration (or whatever configuration you are using with the Profile action) is signed with a "developer" ID. If it's signed with a "distribution" ID, it will prevent debugging and profiling.

Aha! It's definitely some kind of signing issue. We are signing with a Developer ID, because the app is distributed outside the MAS, but if I disable signing, I'm able to run the Leaks profile.


Unfortunately, this is all complicated by us doing our signing in a Build Phases script (so fresh github checkouts by people other than me, can build immediately). Hopefully I can find an environment variable that will let me skip signing if the build is for Instruments!


Thanks very much for your replies 🙂

Is this also true for Network Extensions on iOS devices? I'm signing with Xcode managed profile, and also tried with a manual signing developement ID, and I cannot run leaks on the Network Extensions.

Unknown. There may be something special about those, but I'm not familiar with the architecture. Probably best to file a bug report about leaks not working for Network Extensions and we'll see if there is a workaround.