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

Fix debugger initialization #64523

Merged
merged 3 commits into from
Feb 2, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/coreclr/inc/vptr_list.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ VPTR_CLASS(ReflectionModule)
VPTR_CLASS(AppDomain)
VPTR_CLASS(SystemDomain)

VPTR_CLASS(DomainAssembly)
VPTR_CLASS(PrecodeStubManager)
VPTR_CLASS(StubLinkStubManager)
VPTR_CLASS(ThePreStubManager)
Expand All @@ -38,6 +39,7 @@ VPTR_CLASS(DelegateInvokeStubManager)
VPTR_CLASS(TailCallStubManager)
#endif
VPTR_CLASS(CallCountingStubManager)
VPTR_CLASS(PEAssembly)

VPTR_CLASS(PEImageLayout)
VPTR_CLASS(ConvertedImageLayout)
Expand Down
4 changes: 3 additions & 1 deletion src/coreclr/vm/domainassembly.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,16 @@ enum NotificationStatus

class DomainAssembly final
{
VPTR_BASE_CONCRETE_VTABLE_CLASS(DomainAssembly)
Copy link
Member

Choose a reason for hiding this comment

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

This is a simple C++ type that nothing inherits from now. It does not need a vtable. This fix seems to be injecting useless vtable into the type.

What is the debugger code that is failing? Should the fix be made in that code instead?

Copy link
Member Author

Choose a reason for hiding this comment

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

My goal is to perform a quick fix to unblock the debugger. The debugger is failing in DacDbiInterfaceImpl::GetAssemblyFromDomainAssembly and crashes while handling the assembly load event for System.Private.CoreLib. I'll create an issue to track removing the v-table.

Copy link
Member

Choose a reason for hiding this comment

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

I think the proper fix is to change VPTR to DPTR on these lines in vm:

typedef VPTR(class DomainAssembly)      PTR_DomainAssembly;
typedef VPTR(PEAssembly) PTR_PEAssembly;

The vtables and DAC are super fragile, and we have multiple workarounds like

//-----------------------------------------------------------------------------
// Frame depends on the location of its vtable within the object. This
// superclass ensures that the vtable for Frame objects is in the same
// location under both MSVC and GCC.
//-----------------------------------------------------------------------------
class FrameBase
to make them work on all platforms. If you want to go with this quick fix that adds back the vtables, make sure to test it on all platforms.

Copy link
Member

Choose a reason for hiding this comment

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

I assume there is no way to have a simple test for this?

Copy link
Member Author

Choose a reason for hiding this comment

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

I assume there is no way to have a simple test for this?

CI testing is something we would like to accomplish in the future


public:

// ------------------------------------------------------------
// Public API
// ------------------------------------------------------------

#ifndef DACCESS_COMPILE
~DomainAssembly();
virtual ~DomainAssembly();
DomainAssembly() {LIMITED_METHOD_CONTRACT;};
#endif

Expand Down
2 changes: 2 additions & 0 deletions src/coreclr/vm/peassembly.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ typedef VPTR(PEAssembly) PTR_PEAssembly;

class PEAssembly final
{
VPTR_BASE_CONCRETE_VTABLE_CLASS(PEAssembly)

public:

// ------------------------------------------------------------
Expand Down