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

[release/5.0] Get modules information using proc_pidinfo() on macOS #44748

Merged
merged 1 commit into from
Nov 18, 2020

Conversation

github-actions[bot]
Copy link
Contributor

@github-actions github-actions bot commented Nov 16, 2020

Backport of #42900 to release/5.0

/cc @mikem8361 @k15tfu

Customer Impact

If affects customers that have newer MacOS versions that have XCode 12 installed and “selected” (meaning it is used to build/natively debug code). This PR fixes the issue by removing the dependency on the XCode tool vmmap command.

Testing

It has been in master for a month or so. Testing by @k15tfu (who submitted the PR) and I assume @stevo-knievo who also asked for 5.0/3.1 back porting

Risk

It is fairly low risk and contained to just managed debugging on MacOS.

Previously CreateProcessModules() parsed the output of vmmap command to get
modules addresses/paths on macOS, but on some Macs with latest macOS 10.15.6
vmmap hides full paths to some process modules (.dylibs in non-system folders),
replacing some parts with *:
```
__TEXT                 000000010d8bd000-000000010ddce000 [ 5188K  5188K     0K     0K] r-x/rwx SM=COW          /Users/USER/*/libcoreclr.dylib
```

In particular, it breaks the debugger functionality due to invalid path
`/Users/USER/*/libmscordbi.dylib`, and error code
CORDBG_E_DEBUG_COMPONENT_MISSING is returned.

Now we get modules information by iterating over regions using proc_pidinfo()
in CreateProcessModules().

Fixes #42888
@ghost
Copy link

ghost commented Nov 16, 2020

Tagging subscribers to this area: @eiriktsarpalis, @jeffhandley
See info in area-owners.md if you want to be subscribed.

Issue Details
Description:

Backport of #42900 to release/5.0

/cc @mikem8361 @k15tfu

Customer Impact

Testing

Risk

Author: github-actions[bot]
Assignees: -
Labels:

area-System.Diagnostics.Process

Milestone: -

@mikem8361 mikem8361 self-assigned this Nov 16, 2020
@mikem8361 mikem8361 requested review from mikem8361 and janvorli and removed request for mikem8361 November 16, 2020 18:48
@mikem8361 mikem8361 added the Servicing-consider Issue for next servicing release review label Nov 16, 2020
Copy link
Member

@jeffschwMSFT jeffschwMSFT left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved. Particularly since this was an external break and a few customers are reporting this issue we should take in .NET 5. Please get a cr.

@stevo-knievo
Copy link

Thanks a lot @mikem8361 @k15tfu @jeffschwMSFT!

I was wondering if this will make the way into .NET Core 3.1 as well.

Thanks again

@mikem8361
Copy link
Member

I'm working on 3.1 backport this week.

@mikem8361
Copy link
Member

/cc: @hoyosjs

@hoyosjs hoyosjs linked an issue Nov 16, 2020 that may be closed by this pull request
@mikem8361
Copy link
Member

@k15tfu, @stevo-knievo, @jeffschwMSFT, @hoyosjs, @gregg-miskelly

As it turns out, this does not need to be backported to 3.1 or 2.1 because it only affects/fixes "dbgshim" (libdbgshim.dylib on MacOS) which is picked up by Visual Studio/VSCode and shipped with it.

@stevo-knievo
Copy link

Thanks for the update @mikem8361. I much appreciate it.

I experiencing the issue with Jetbrains Rider together with Azure Function projects. I can't debug Azure Function projects (.NET Core 3.1). I'm getting the following error:

One or more errors occurred. (One or more errors occurred. (CLR load callback is already in error state. A debug component is not installed. (0x80131C3C). The error code is CORDBG_E_DEBUG_COMPONENT_MISSING, or 0x80131C3C.))

Here the issue I opened on the JetBrains side.
https://youtrack.jetbrains.com/issue/RIDER-51166

If I understand you correctly I need to point the JetBrains guys to your previous comment because they need it to fix it on their side. Is that correct?

Thanks for your help. Stefan

@k15tfu
Copy link
Contributor

k15tfu commented Nov 17, 2020

@mikem8361 Yes. But for native apps trying to create ICorDebug, there is no libdbgshim.dylib other than the one in the target process's runtime directory. So we really need this fix to be backported to 3.1/2.1, otherwise the users (debuggers) will have to download & use their own libdbgshim.dylib to be able to debug end user apps.

Now this is not required, and you can simply use the one you found.

@jeffschwMSFT jeffschwMSFT added this to the 5.0.x milestone Nov 17, 2020
@leecow leecow added Servicing-approved Approved for servicing release and removed Servicing-consider Issue for next servicing release review labels Nov 17, 2020
@mikem8361
Copy link
Member

We strongly recommend that managed debuggers include and shipped dbgshim with their product. It was always our intent that dbgshim ship with debuggers even though it probably wasn't clear. Shipping the dbgshim binaries from the next 5.0.x service release (which will include this PR) will allow the debuggers to work with all the previous runtime versions (5.0.0, 3.1.x and 2.1.x).

Some of the reasons are:

  1. The current and upcoming single-file support where there isn't any separate runtime files. The runtime is "linked" into the app. The debugger support modules like the DAC and DBI have to be downloaded.
  2. In the future dbgshim may be moved out of the shared runtime and shipped out of band.

/cc: @noahfalk, @tommcdon

@ilushka85
Copy link

So what is the best way to fix this for something like debugging in Jetbrains rider? just drop in the new libdbgshim.dylib?

@mikem8361 mikem8361 merged commit 030f593 into release/5.0 Nov 18, 2020
@mikem8361 mikem8361 deleted the backport/pr-42900-to-release/5.0 branch November 18, 2020 01:19
@k15tfu
Copy link
Contributor

k15tfu commented Nov 19, 2020

@mikem8361 Okay, I got your points. Thank you for the clarification.

@ghost ghost locked as resolved and limited conversation to collaborators Dec 19, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Debugging not working with XCode 12 selected
8 participants