Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Failed to gain authorization" #40

Closed
kettle11 opened this issue Jun 20, 2021 · 5 comments · Fixed by #46
Closed

"Failed to gain authorization" #40

kettle11 opened this issue Jun 20, 2021 · 5 comments · Fixed by #46

Comments

@kettle11
Copy link

When I try to run an Allocations profile I get the following error:

      Failed instruments errored: [ERROR] Run issues detected (trace is still ready to be viewed):
* Failed to gain authorization

I'm on an M1 Mac running macOS Big Sur 11.4.

I suspect that it's related to this issue: https://developer.apple.com/forums/thread/681687

But if that were the case then it seems likely other users of cargo-instruments would be hitting it as well. Is anyone else hitting this issue?

@cmyr
Copy link
Owner

cmyr commented Jun 22, 2021

I'm still not running big sur anywhere, although I will be in a week or so.

@hkratz
Copy link

hkratz commented Aug 6, 2021

You have to replace the ad-hoc signature of the binary to be profiled with a new one that has the com.apple.security.get-task-allow entitlement enabled. You can do it like this:

  1. Create an ent.plist file with the following contents in your home dir:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
    <dict>
        <key>com.apple.security.get-task-allow</key>
        <true/>
    </dict>
</plist>
  1. Build the binary.
  2. Resign it with a new ad-hoc signature including the entitlement: codesign -s - -f --entitlements ~/ent.plist <path to binary>
  3. Run the profiler with xcrun xctrace record --template 'Allocations' --launch -- <path to binary> [args...]

@cmyr
Copy link
Owner

cmyr commented Aug 6, 2021

@hkratz this sounds like something I should be able to do automatically as part of the tool?

@hkratz
Copy link

hkratz commented Aug 6, 2021

@cmyr Yes. It would probably be best if you could do this by setting some magic linker options for rustc. The linker is the one doing the ad-hoc signing in the first place so I assume it can also include the entitlement somehow.

@chotchki
Copy link

I think we could hack around this by doing an adhoc signature that's mentioned in this blog post

https://eclecticlight.co/2020/08/22/apple-silicon-macs-will-require-signed-code/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants