Skip to content
New issue

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

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

Already on GitHub? # to your account

Unable to attach to macOS process #1230

Open
n8ta-msft opened this issue Dec 22, 2023 · 1 comment
Open

Unable to attach to macOS process #1230

n8ta-msft opened this issue Dec 22, 2023 · 1 comment

Comments

@n8ta-msft
Copy link

This code does not seem to work on a dotnet project out of the box.

using DataTarget dataTarget = DataTarget.AttachToProcess(Process.GetCurrentProcess().Id, true);

Fails with

Unhandled exception. Microsoft.Diagnostics.Runtime.ClrDiagnosticsException: Could not attach to process 55656, errno: 1
   at Microsoft.Diagnostics.Runtime.MacOS.MacOSProcessDataReader..ctor(Int32 processId, Boolean suspend)
   at Microsoft.Diagnostics.Runtime.DataTarget.AttachToProcess(Int32 processId, Boolean suspend)
   at Program.Main() in /Users/n8ta/SIG8/test_app/Program.cs:line 41

I have a repro project here https://github.com/n8ta-msft/clrmd-repro for arm64 macOS.
I suspect I need to sign with some specific entitlements but I have not been able to figure out which.

@hoyosjs
Copy link
Member

hoyosjs commented Jan 8, 2024

The problem might really be that the MacOSProcessDataReader will use ptrace given suspend: true. See https://lkml.org/lkml/2006/8/31/24. The scenario has been reported as largely affecting self-diagnostic ptrace, but the change was intentional. The change is old enough it's likely to have been ported to the ptrace implementation that macOS uses.

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

No branches or pull requests

2 participants