Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Conversation

@davmason
Copy link

Changes I intend to be permanent for local gc:

  • Turned off HandleTable shouldinjectfault for local gc
  • Included redhawk versions of validate, promote, etc for standalone gc
  • objecthandle.cpp - turned off check for kEtwGCRootFlagsWeakRef-
  • objecthandle.cpp - deleted newholder, it was just one instance
  • Copied ClrSafeInt to local gc

Changes I intend to be temporary and fixed in future issues

  • Disabled AnalyzeSurvivorsRequested and DACNotifyGcMarkEnd, they used GCNotifications which needs to be changed to use in local gc
  • Disabled NumaNodeInfo

@davmason
Copy link
Author

Opened #17770 for numanodeinfo

@davmason
Copy link
Author

Opened #17771 for AnalyzeSurvivorsRequested and DACNotifyGcMarkEnd

@davmason davmason requested review from Maoni0 and sywhang April 25, 2018 08:44
@@ -0,0 +1,810 @@
// Licensed to the .NET Foundation under one or more agreements.
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 it is overkill to include copy of this whole file for a single overflow check.

Copy link
Member

Choose a reason for hiding this comment

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

Also, the overflow check that this is for is pretty useless. You can just replace it by assert.

Copy link
Author

Choose a reason for hiding this comment

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

@jkotas We also use S_SIZE_T for init() (see gc.cpp:5059), although looking at the code I don't think it is currently protecting anything. It is written as S_SIZE_T safe_sniff_buf_size = S_SIZE_T(1 + n_heaps*n_sniff_buffers + 1);, which seems like any overflow would happen in the calculation before it is passed to the S_SIZE_T constructor.

I'm fine with getting rid of the file, I agree it's pretty heavyweight for how it's used. I was just being cautious because it's tricky to write overflow code so the compiler doesn't defeat it

break;

#if defined(FEATURE_COMINTEROP) && !defined(FEATURE_REDHAWK)
#if defined(FEATURE_COMINTEROP) && !defined(FEATURE_REDHAWK) && !defined(BUILD_AS_STANDALONE)
Copy link
Member

Choose a reason for hiding this comment

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

COM interop is broken with standalone GC. Do you have a follow up bug to fix this?

Copy link
Member

Choose a reason for hiding this comment

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

We have pretty light test coverage for COM interop in the open sourced tests today, so you might not have noticed the breakage if you have just run CoreCLR open sourced tests.

Copy link
Author

Choose a reason for hiding this comment

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

I have only run the open source tests, and they all pass under local gc. But they also passed when it was compiled with FEATURE_REDHAWK so they don't test the corner cases of the gc.

I opened https://github.com/dotnet/coreclr/issues/17789

CONTRACTL_END;

#if defined( _DEBUG) && !defined(FEATURE_REDHAWK)
#if defined( _DEBUG) && !defined(FEATURE_REDHAWK) && !defined(BUILD_AS_STANDALONE)
Copy link
Member

Choose a reason for hiding this comment

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

It would be better to delete the inject faults from here, and move them to the EE side instead.

Copy link
Member

Choose a reason for hiding this comment

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

does anyone actually use this? I have not seen it myself


In reply to: 184080041 [](ancestors = 184080041)

Copy link
Member

Choose a reason for hiding this comment

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

It has been used for SQL testing 10+ years ago. It is not actively used for anything. I guess we can just delete it.

Copy link
Member

Choose a reason for hiding this comment

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

yeah, I vote for deleting it.

Copy link
Author

Choose a reason for hiding this comment

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

Ok, it's deleted now

#endif //TRACE_GC

#ifndef FEATURE_REDHAWK
#if !defined(FEATURE_REDHAWK) && !defined(BUILD_AS_STANDALONE)
Copy link
Member

Choose a reason for hiding this comment

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

It would be better to move this to somewhere in vm\gcenv.*.

BOOL AnalyzeSurvivorsRequested(int condemnedGeneration)
{
#ifndef BUILD_AS_STANDALONE
// Is the list active?
Copy link
Member

Choose a reason for hiding this comment

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

What is the end-user visible debugger feature that is not going to work with standalone GC because of this?

Copy link
Author

Choose a reason for hiding this comment

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

I think it's just some events are written to debugger on a gc, the only thing I could find that uses it is

STDMETHODIMP OnGcEvent(GcEvtArgs gcEvtArgs)
{
// by default don't stop on these notifications...
m_dbgStatus = DEBUG_STATUS_GO_HANDLED;
IXCLRDataProcess2* idp2 = NULL;
if (SUCCEEDED(g_clrData->QueryInterface(IID_IXCLRDataProcess2, (void**) &idp2)))
{
if (gcEvtArgs.typ == GC_MARK_END)
{
// erase notification request
GcEvtArgs gea = { GC_MARK_END, { 0 } };
idp2->SetGcNotification(gea);
s_condemnedGen = bitidx(gcEvtArgs.condemnedGeneration);
ExtOut("CLR notification: GC - Performing a gen %d collection. Determined surviving objects...\n", s_condemnedGen);
// GC_MARK_END notification means: give the user a chance to examine the debuggee
m_dbgStatus = DEBUG_STATUS_BREAK;
}
}
return S_OK;
}

@noahfalk please correct me if I missed something

Copy link
Member

Choose a reason for hiding this comment

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

That OnGcEvent method is part of the implementation for !FindRoot
https://github.com/dotnet/coreclr/blob/master/src/ToolBox/SOS/Strike/sosdocs.txt#L1918
Without this event !FindRoot -gen won't ever break back into the debugger.

// Let's create a new node
NewHolder<HandleTableMap> newMap;
newMap = new (nothrow) HandleTableMap;
HandleTableMap *newMap = new (nothrow) HandleTableMap;
Copy link
Member

Choose a reason for hiding this comment

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

Why have you removed the holder? It is a pattern that we prefer to use wherever we can.

Copy link
Member

@jkotas jkotas Apr 25, 2018

Choose a reason for hiding this comment

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

GC is not using holders anywhere else. I do not think it is worth pulling in the whole holder machinery into local GC just for the one use.

Copy link
Member

Choose a reason for hiding this comment

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

Ah, ok. I have thought we already had it in.

@davmason
Copy link
Author

@jkotas @Maoni0 Can you take a look?

These were the outstanding issues:

  • Com interop is still missing
    • Tracked by #17789
  • DAC features are still missing
    • Tracked by #17771
  • Jan suggested it would be better to move handle table fault injection to the VM side
    • Won't fix - there are way too many overloads and call sites to do this efficiently, I think it is better to turn off handle table fault injection for local GC. It is not a frequently used item and doesn't matter for production scenarios

Let me know if you have anything else you're concerned about.

bool virtual_alloc_commit_for_heap(void* addr, size_t size, int h_number)
{
#if defined(MULTIPLE_HEAPS) && !defined(FEATURE_REDHAWK) && !defined(FEATURE_PAL)
#if defined(MULTIPLE_HEAPS) && !defined(FEATURE_REDHAWK) && !defined(FEATURE_PAL) && !defined(BUILD_AS_STANDALONE)
Copy link
Member

Choose a reason for hiding this comment

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

this needs to work for standalone GC though... numa is pretty common these days.

Copy link
Author

Choose a reason for hiding this comment

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

Filed #19417 to track it

Copy link
Member

@Maoni0 Maoni0 left a comment

Choose a reason for hiding this comment

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

LGTM!

@davmason
Copy link
Author

@dotnet-bot test Windows_NT x64 Release CoreFX Tests

@davmason
Copy link
Author

@dotnet-bot test Windows_NT x64 Checked CoreFX Tests

@davmason davmason merged commit d4738d1 into dotnet:master Aug 11, 2018
@davmason davmason deleted the redhawk branch August 14, 2018 20:00
janvorli added a commit to janvorli/coreclr that referenced this pull request Oct 5, 2018
The function was incorrectly rounding the dwCommit down instead of up
to OS_PAGE_SIZE. It accidentally works for OSes where page size is 4096
bytes, because the dwCommit is 4096. But for ARM64 Linux distros where
the page size is 64kB, this was committing zero bytes and so the runtime
initialization was crashing a bit later when it tried to access the
memory it was supposed to be commited.

This problem was introduced in dotnet#17769.
janvorli added a commit to janvorli/coreclr that referenced this pull request Oct 5, 2018
The function was incorrectly rounding the dwCommit down instead of up
to OS_PAGE_SIZE. It accidentally works for OSes where page size is 4096
bytes, because the dwCommit is 4096. But for ARM64 Linux distros where
the page size is 64kB, this was committing zero bytes and so the runtime
initialization was crashing a bit later when it tried to access the
memory it was supposed to be commited.

This problem was introduced in dotnet#17769.
janvorli added a commit to janvorli/coreclr that referenced this pull request Oct 6, 2018
The function was incorrectly rounding the dwCommit down instead of up
to OS_PAGE_SIZE. It accidentally works for OSes where page size is 4096
bytes, because the dwCommit is 4096. But for ARM64 Linux distros where
the page size is 64kB, this was committing zero bytes and so the runtime
initialization was crashing a bit later when it tried to access the
memory it was supposed to be commited.

This problem was introduced in dotnet#17769.
jkotas pushed a commit that referenced this pull request Oct 8, 2018
The function was incorrectly rounding the dwCommit down instead of up
to OS_PAGE_SIZE. It accidentally works for OSes where page size is 4096
bytes, because the dwCommit is 4096. But for ARM64 Linux distros where
the page size is 64kB, this was committing zero bytes and so the runtime
initialization was crashing a bit later when it tried to access the
memory it was supposed to be commited.

This problem was introduced in #17769.
A-And pushed a commit to A-And/coreclr that referenced this pull request Nov 20, 2018
The function was incorrectly rounding the dwCommit down instead of up
to OS_PAGE_SIZE. It accidentally works for OSes where page size is 4096
bytes, because the dwCommit is 4096. But for ARM64 Linux distros where
the page size is 64kB, this was committing zero bytes and so the runtime
initialization was crashing a bit later when it tried to access the
memory it was supposed to be commited.

This problem was introduced in dotnet#17769.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants