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

Block debugger attach after any ApplyUpdate changes #50200

Merged
6 commits merged into from
Mar 26, 2021

Conversation

mikem8361
Copy link
Member

DebugActiveProcess now fails if any metadata updates have been applied with the ApplyUpdate API.

Add better error message for ApplyUpdate while debugging.

@ghost
Copy link

ghost commented Mar 24, 2021

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

Issue Details

DebugActiveProcess now fails if any metadata updates have been applied with the ApplyUpdate API.

Add better error message for ApplyUpdate while debugging.

Author: mikem8361
Assignees: mikem8361
Labels:

area-Diagnostics-coreclr

Milestone: -

@jkotas
Copy link
Member

jkotas commented Mar 25, 2021

cc @lambdageek

Copy link
Member

@stephentoub stephentoub left a comment

Choose a reason for hiding this comment

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

What is the error message someone will get if they try to attach after an edit?

@mikem8361
Copy link
Member Author

The debugger API returns CORDBG_E_DEBUGGING_NOT_POSSIBLE HRESULT when there have been updates. It is the closest error I could come up with. VS displays the following message as a result:

"Unable to attach to the process. Debugging is not possible due to an incompatibility within the CLR implementation"

@jkotas
Copy link
Member

jkotas commented Mar 25, 2021

Should we define a new HRESULT for this so that VS can give better error message in this situation?

@stephentoub
Copy link
Member

Thanks. What would it take to do better (after this PR) such that the error message is more descriptive about the particular case? Introduce a new error code and teach VS what to say in response?

@stephentoub
Copy link
Member

(Jan beat me to my question by 45 seconds apparently :-)

@mikem8361
Copy link
Member Author

The problem with a new HRESULT is that VS will display something very generic until they do another release.

@mikem8361
Copy link
Member Author

Like "Unable to attach. Unknown error: 0x8xxxxxxxx" I'm assuming.

@stephentoub
Copy link
Member

I think that's ok. Ideally we could get the error=>string mapping into a near-term 16.xx release, but even if we couldn't, I'd rather have a better experience here for the longer term. After all, one of the primary purposes of having this block in place is to provide a better user experience that's explanatory of the situation than what would happen if you could successfully attach but find yourself unable to meaningfully debug and not know why. And if it is "Unable to attach. Unknown error: 0x8xxxxxxxx", worst case that 0x8xxxxxxxx becomes searchable and we can ensure the right information is exposed in docs about what that message means.

@mikem8361
Copy link
Member Author

How about:

#define CORDBG_E_ASSEMBLY_UPDATES_APPLIED EMAKEHR(0x1c69)

The resulting VS message is:

"Unable to attach to the process. Operation not supported. Unknown error: 0x80131c69"

@@ -383,6 +383,7 @@
#define CORDBG_E_DATA_TARGET_ERROR EMAKEHR(0x1c61)
#define CORDBG_E_NO_IMAGE_AVAILABLE EMAKEHR(0x1c64)
#define CORDBG_E_UNSUPPORTED_DELEGATE EMAKEHR(0x1c68)
#define CORDBG_E_ASSEMBLY_UPDATES_APPLIED EMAKEHR(0x1c69)
Copy link
Member

Choose a reason for hiding this comment

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

Could you please also add it to src\coreclr\inc\corerror.xml ?

@mikem8361
Copy link
Member Author

mikem8361 commented Mar 25, 2021 via email

@stephentoub
Copy link
Member

"Unable to attach to the process. Operation not supported. Unknown error: 0x80131c69"

LGTM, thanks. Then we'll just need to get a dedicated, descriptive message added into VS for this new error code for when someone's able to use that newer version.

@ghost
Copy link

ghost commented Mar 25, 2021

Hello @mikem8361!

Because this pull request has the auto-merge label, I will be glad to assist with helping to merge this pull request once all check-in policies pass.

p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (@msftbot) and give me an instruction to get started! Learn more here.

@ghost ghost merged commit e503be0 into dotnet:main Mar 26, 2021
@mikem8361 mikem8361 deleted the blockattach branch March 26, 2021 03:14
@ghost ghost locked as resolved and limited conversation to collaborators Apr 25, 2021
@karelz karelz added this to the 6.0.0 milestone May 20, 2021
This pull request was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants