The DoTransform method in TransformCollectionAndObjectInitializers removes instructions from the block while they are being iterated through in the Run method above DoTransform.
I can reproduced this with the following code compiled in Release mode.
class CrashTest
{
class Data
{
public object Obj;
}
class Items
{
public void SetItem(int i, object item) { }
}
object Item(string s, Data d) => new object();
void Test()
{
Items items = null;
int num = 0;
for (int i = 0; i < 2; i++)
{
if (num < 10)
items.SetItem(num, Item(string.Empty, new Data { Obj = null }));
}
}
}
The
DoTransformmethod inTransformCollectionAndObjectInitializersremoves instructions from the block while they are being iterated through in theRunmethod above DoTransform.I can reproduced this with the following code compiled in Release mode.