-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
Debugging with LLDB doesn't work for universal2 installer on macOS Big Sur #88400
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
Comments
I've installed python 3.9.5 using the universal2 installer on my M1 MacBook. Debugging this python using lldb doesn't work because the debugger cannot attach to the (newly launched) binary. This appears to be due to a missing entitlement in the signed executable. Background: https://developer.apple.com/forums/thread/676028?answerId=666834022#666834022 (in particular the first reply). |
There's a reason for that. What the discussion in that link fails to note is that elsewhere Apple warns that that entitlement is understandably prohibited in distributions submitted to the Apple notarization service. See the "Avoid the Get-Task-Allow Entitlement" section here: https://developer.apple.com/documentation/security/notarizing_macos_software_before_distribution/resolving_common_notarization_issues. I haven't verified that that is still the case but I'd be surprised if it weren't. I think one solution (and possibly the best) might be to manually re-codesign the installed binaries if you need to use lldb with the python.org binaries. If someone comes up with something that works, we could document it somewhere with appropriate warnings about security risks and advice to reinstall when finished. |
Should we add documentation about this? The truly annoying bit about that discussion is that its probably easier to just install gdb and use that to debug extensions. |
I have found the following workaround.
After step 3, my_entitlements.xml may look like this<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
"https://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.automation.apple-events</key>
<true/>
<key>com.apple.security.cs.allow-dyld-environment-variables</key>
<true/>
<key>com.apple.security.cs.disable-executable-page-protection</key>
<true/>
<key>com.apple.security.cs.disable-library-validation</key>
<true/>
</dict>
</plist>
After step 4, my_entitlements.xml may look like this<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
"https://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.automation.apple-events</key>
<true/>
<key>com.apple.security.cs.allow-dyld-environment-variables</key>
<true/>
<key>com.apple.security.cs.disable-executable-page-protection</key>
<true/>
<key>com.apple.security.cs.disable-library-validation</key>
<true/>
<key>com.apple.security.get-task-allow</key>
<true/>
</dict>
</plist>
@ronaldoussoren @ned-deily Could you please verify if this can be used as an unsafe solution? |
In addition, I would like to provide more details on why this issue is important. Apart from the extensions debugging mentioned above, this issue is critical for the Currently, the workaround for macOS users, besides the thorny way of signing Speaking of other development tools that have also been impacted by missing I noticed in #84379 that the idea is to keep the entitlements list as short as possible, and I completely understand the reason behind that. However, considering that this particular issue is critical for Python tooling, I would like to highlight this and request the maintainers' opinions. Cc @ned-deily |
[...]
An easier solution is to drop steps 1 to 4 and replace step 6 by
On an Intel Mac you can leave of step 6. This is basically what I do on my M1 laptop when I need to debug, although I also do this to You loose the hardened runtime that way, and maybe some access to more sensitive system APIs, but neither of them should affect debugging for more code. Note that we don't have a choice w.r.t. the hardened runtime: If we want to distribute a signed installer we have to use the hardened runtime. I'd be -1 on starting to ship a non-signed installer, for various reasons. Adding |
@ned-deily : Get Task Allow should be OK according to the page you mentioned earlier, it says:
We ship with the |
Thanks, @ronaldoussoren. I'll test packaging with that. |
@ronaldoussoren Thank you for describing a more straightforward workaround for the issue. @ned-deily I greatly appreciate your attention to this issue. Please let me know if there is anything I can do to help move this forward. For example, I would be happy to verify an experimental package build for debugging purposes. |
Sorry this slipped under the radar! As of Python 3.14.0b1, the python.org macOS binaries are now signed with the |
It works for me, in a fresh install of 3.14.0b1 using the python.org installer I can use LLDB to debug the python interpreter. Thanks! |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: