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

Unable to debug Emacs in debugger #326

Open
tko opened this issue Mar 5, 2023 · 6 comments
Open

Unable to debug Emacs in debugger #326

tko opened this issue Mar 5, 2023 · 6 comments

Comments

@tko
Copy link

tko commented Mar 5, 2023

lldb lacking some permissions:

error: process exited with status -1 (attach failed (Not allowed to attach to process. Look in the console messages (Console.app), near the debugserver entries, when the attach failed. The subsystem that denied the attach permission will likely have logged an informative message about why it was denied.))

from Console.app:

macOSTaskPolicy: (com.apple.debugserver) may not get the task control port of (Emacs) (pid: 75620): (Emacs) is hardened, (Emacs) doesn't have get-task-allow, (com.apple.debugserver) is a declared debugger(com.apple.debugserver) is not a declared read-only debugger

emacs-28.2-mac-9.1 (cask)
macOS Monterey 12.6.3

(trying to figure why doom emacs freezes hard, seems like maybe something to do with company/completions; C-g nor USR1/USR2 do anything, need to kill -9)

@tko
Copy link
Author

tko commented Mar 6, 2023

Apparently this makes Emacs.app runnable in debugger:

codesign -d --xml --entitlements - ./Emacs.app > e.xml
/usr/libexec/PlistBuddy -c "Add :com.apple.security.get-task-allow bool true" ./e.xml
codesign -s - -f --entitlements e.xml ./Emacs.app

However that also seems to stop it from freezing, even when running normally.

@railwaycat
Copy link
Owner

I haven't try to run debugger on a cask bundle, I guess you may want to remove the signature first by codesign --remove-signature or similar approaching.

I may suggest use the emacs-mac build from homebrew formula for debugging or build from upstream https://bitbucket.org/mituharu/emacs-mac/src/master/, unless you are debugging a cask specific issue.

@tko
Copy link
Author

tko commented Mar 23, 2023

I don't really even quite understand why the two even exist. For me the cask looks like one that needs less recompiling on my end. 🤷

@itollefsen
Copy link

I have Emacs installed from prebuilt binaries. I experienced the same thing. Magit would freeze and trigger a trap while writing commit messages. I tried debugging Emacs and encountered the same issue.

By giving it the get-task-allow entitlement (I had to pass --deep to codesign for it to work), it just stopped freezing.

For what it's worth, I believe the freeze was somehow caused by company trying to complete something from a dictionary in text mode.

@ldangelo
Copy link

I was trying to debug an issue where emacs was hanging while lsp was active. I added the code signing above (so I could debug the problem) and for now the problem has gone away. I'm wondering how code signing is affecting Emacs overall? Clearly it is doing something? Before code signing I would get 'frequent' segv's E_BAD_ACCESS. I will report back here if 'signing' fixed the issue or not.

@ldangelo
Copy link

No joy! Finally 'hung' here is the stack trace...

`* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x80)

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

No branches or pull requests

4 participants