Skip to content

ArgumentOutOfRangeException in TransformCollectionAndObjectInitializers.DoTransform #855

@mmusu3

Description

@mmusu3

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 }));
        }
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions