Repository navigation
Closed
Labels
area-TypeSystem-coreclrhelp wanted[up-for-grabs] Good issue for external contributorsin-prThere is an active PR which will close this issue when it is merged
Milestone
Description
Description
We have two pointer pMT dereferences:
runtime/src/coreclr/vm/typedesc.cpp
Line 888 in cc2670b
| GetModule()->GetAssembly()->ThrowTypeLoadException(pInternalImport, pMT->GetCl(), IDS_CLASSLOAD_BADFORMAT); |
runtime/src/coreclr/vm/typedesc.cpp
Line 909 in cc2670b
| GetModule()->GetAssembly()->ThrowTypeLoadException(pInternalImport, pMT->GetCl(), IDS_CLASSLOAD_BADFORMAT); |
And they are absolutely identical. But before the second dereference there is a check for NULL, before the first there is not. I assume two options. The first option is an unnecessary check. The second option is that the pointer at the first dereference can really be NULL. Between these two dereferences, the pointer
pMT itself does not change. Only the following lines:runtime/src/coreclr/vm/typedesc.cpp
Lines 890 to 898 in cc2670b
| _ASSERTE(tkParam == GetToken()); | |
| TypeHandle thConstraint = ClassLoader::LoadTypeDefOrRefOrSpecThrowing(GetModule(), tkConstraintType, | |
| &typeContext, | |
| ClassLoader::ThrowIfNotFound, | |
| ClassLoader::FailIfUninstDefOrRef, | |
| ClassLoader::LoadTypes, | |
| level); | |
| constraints[i++] = thConstraint; |
Found by Linux Verification Center (portal.linuxtesting.ru) with SVACE.
Author A. Voronin.
Reacted by TERESH1
Metadata
Metadata
Assignees
Labels
area-TypeSystem-coreclrhelp wanted[up-for-grabs] Good issue for external contributorsin-prThere is an active PR which will close this issue when it is merged
Activity
steveisok commentedon Jul 25, 2024
Not 100% sure, but a good explanation may be the first dereference never gets hit when taking the else path in:
runtime/src/coreclr/vm/typedesc.cpp
Lines 855 to 870 in cc2670b
lambdageek commentedon Jul 26, 2024
yea I think there's probably a situation where we come in from the "else" case that @steveisok mentioned (line 855) and then hit try to throw from line 888.
But it would only happen with malformed IL, I think.
There might be a valid issue here, but the majority of the work will be in crafting an appropriately malformed assembly for a test case.
PRs welcome
fix null dereference in LoadConstraints for generic types (dotnet#136826