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

[EnC] CoreCLR assertion in System.Reflection.Metadata.ApplyUpdateTest.TestGenericAddStaticField #87574

Open
lambdageek opened this issue Jun 14, 2023 · 7 comments · Fixed by #89145
Labels
area-Diagnostics-coreclr disabled-test The test is disabled in source code against the issue
Milestone

Comments

@lambdageek
Copy link
Member

The test triggers an assertion:

Assert failure(PID 2148 [0x00000864], Thread: 17217 [0x4341]): pos >= 0 && pos < pMT->GetNumStaticFields()
    File: /Users/runner/work/1/s/src/coreclr/vm/memberload.cpp Line: 369
    Image: /private/tmp/helix/working/B15A0A10/p/dotnet

Test was added in #87285

@ghost ghost added the untriaged New issue has not been triaged by the area owner label Jun 14, 2023
@ghost
Copy link

ghost commented Jun 14, 2023

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

Issue Details

The test triggers an assertion:

Assert failure(PID 2148 [0x00000864], Thread: 17217 [0x4341]): pos >= 0 && pos < pMT->GetNumStaticFields()
    File: /Users/runner/work/1/s/src/coreclr/vm/memberload.cpp Line: 369
    Image: /private/tmp/helix/working/B15A0A10/p/dotnet

Test was added in #87285

Author: lambdageek
Assignees: -
Labels:

area-Diagnostics-coreclr

Milestone: -

@lambdageek
Copy link
Member Author

attn: @mikelle-rogers

From offline discussion with @AaronRobinsonMSFT

the comment points to GetFieldDescByIndex() which was updated. See

// Check if the field index is for an EnC field lookup.
// See GetIndexForFieldDesc() for when this is applied and why.
if ((fieldIndex & EnCFieldIndex) == EnCFieldIndex)
{
DWORD rid = fieldIndex & ~EnCFieldIndex;
LOG((LF_ENC, LL_INFO100, "MT:GFDBI: rid:0x%08x\n", rid));
mdFieldDef tokenToFind = TokenFromRid(rid, mdtFieldDef);
EncApproxFieldDescIterator fdIterator(
this,
ApproxFieldDescIterator::ALL_FIELDS,
(EncApproxFieldDescIterator::FixUpEncFields | EncApproxFieldDescIterator::OnlyEncFields));
PTR_FieldDesc pField;
while ((pField = fdIterator.Next()) != NULL)
{
mdFieldDef token = pField->GetMemberDef();
if (tokenToFind == token)
{
LOG((LF_ENC, LL_INFO100, "MT:GFDBI: Found pField:%p\n", pField));
return pField;
}
}
LOG((LF_ENC, LL_INFO100, "MT:GFDBI: Failed to find rid:0x%08x\n", rid));
return NULL;
}

if (pFD->IsStatic() && pMT->HasGenericsStaticsInfo())
{
//
// <NICE> this is duplicated logic GetFieldDescByIndex </NICE>
//
INDEBUG(mdFieldDef token = pFD->GetMemberDef();)
DWORD pos = static_cast<DWORD>(pFD - (pMT->GetApproxFieldDescListRaw() + pMT->GetNumIntroducedInstanceFields()));
_ASSERTE(pos >= 0 && pos < pMT->GetNumStaticFields());
pFD = pMT->GetGenericsStaticFieldDescs() + pos;
_ASSERTE(pFD->GetMemberDef() == token);
_ASSERTE(!pFD->IsSharedByGenericInstantiations());
_ASSERTE(pFD->GetEnclosingMethodTable() == pMT);
}

We need to add a test and reconcile these two paths. Hopefully removing the code duplication to avoid this in the future.

@lambdageek lambdageek added this to the 8.0.0 milestone Jun 14, 2023
@ghost ghost removed the untriaged New issue has not been triaged by the area owner label Jun 14, 2023
@AaronRobinsonMSFT
Copy link
Member

@mikelle-rogers Please let me know if you'd like me to look into this.

@lambdageek lambdageek added the disabled-test The test is disabled in source code against the issue label Jun 29, 2023
@ghost ghost added the in-pr There is an active PR which will close this issue when it is merged label Jul 19, 2023
@mikelle-rogers
Copy link
Member

After taking out the assert _ASSERTE(pos >= 0 && pos < pMT->GetNumStaticFields()); this fails in memberload.cpp, in GetDescFromMemberRef, with the field with name <>9__1_0. It fails with an AV in clr when this field calls GetMemberDef().

@AaronRobinsonMSFT

@mikelle-rogers mikelle-rogers removed their assignment Jul 20, 2023
@ghost ghost added in-pr There is an active PR which will close this issue when it is merged and removed in-pr There is an active PR which will close this issue when it is merged labels Jul 20, 2023
@mikelle-rogers mikelle-rogers self-assigned this Jul 21, 2023
@ghost ghost removed the in-pr There is an active PR which will close this issue when it is merged label Jul 21, 2023
@mikelle-rogers
Copy link
Member

Close via pull request #89145

@ghost ghost locked as resolved and limited conversation to collaborators Aug 21, 2023
@jkotas
Copy link
Member

jkotas commented Oct 8, 2024

We still have tests disabled against this issue

[ActiveIssue("https://github.com/dotnet/runtime/issues/87574", TestRuntimes.CoreCLR)]

@jkotas jkotas reopened this Oct 8, 2024
@jkotas jkotas modified the milestones: 8.0.0, 10.0.0 Oct 8, 2024
@tommcdon
Copy link
Member

Moving to future as this issue does not seem to be affecting any customer related scenarios

@tommcdon tommcdon modified the milestones: 10.0.0, Future Jan 28, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-Diagnostics-coreclr disabled-test The test is disabled in source code against the issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants