Skip to content

Commit 8fbfb32

Browse files
Be more resilient against invalid metadata in fields (#99944)
Addresses some of the problems seen in #99580. We already check methods and types are loadable. Should do the same for fields.
1 parent be76968 commit 8fbfb32

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/RootingHelpers.cs

+10
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,16 @@ public static bool TryGetDependenciesForReflectedField(ref DependencyList depend
227227
((MetadataType)owningType).MakeInstantiatedType(inst));
228228
}
229229

230+
try
231+
{
232+
// Make sure we're not putting something into the graph that will crash later.
233+
factory.TypeSystemContext.EnsureLoadableType(field.FieldType);
234+
}
235+
catch (TypeSystemException)
236+
{
237+
return false;
238+
}
239+
230240
dependencies.Add(factory.ReflectedField(field), reason);
231241

232242
return true;

0 commit comments

Comments
 (0)