Skip to content

[EnC] CustomAttribute rows in delta seem out of order #60125

@lambdageek

Description

@lambdageek

Version Used: using https://github.com/dotnet/hotreload-utils 1.0.2-alpha.0.22157.2 which uses roslyn 4.2.0-3.22156.4

Steps to Reproduce:

Compile the following baseline and apply changes below, then look at the metadata delta with mdv

Baseline:

// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System;


namespace System.Reflection.Metadata.ApplyUpdate.Test
{
    public class AddNestedClass
    {
        public AddNestedClass()
        {
        }

        public string TestMethod()
        {
            return "123";
        }

    }
}

Modification:

// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System;


namespace System.Reflection.Metadata.ApplyUpdate.Test
{
    public class AddNestedClass
    {
        public AddNestedClass()
        {
        }

        public string TestMethod()
        {
            var n = new Nested();
	    n.Evt += new Action<string> (n.DefaultHandler);
            return n.buf;
        }

        private class Nested {
            public Nested() { }
	    public event Action<string> Evt;

	    public void RaiseEvt () {
		Evt ("789");
	    }

	    public string buf;

	    public void DefaultHandler (string s) {
		this.buf = s;
	    }
        }
    }
}

Compile with nullability enabled.

The mdv output is attached:
add-event.mdv.txt

Expected Behavior:

the custom attribute with parent 0x06000007 in both the baseline and Generation 1 will be at row 0x1a

Actual Behavior:

The EnCMap says:

1c: 0x0c00001a (CustomAttribute)  0    0x00001a  update  

So row 0x1a of the Custom Attributes table is updated by row 1 from Generation 1:

1: 0x04000004 (Field)      0x0a000012 (MemberRef)  01-00-00-00 (#356/7e)              

which has a completely different parent and .ctor

The actual update to Parent 0x06000007 is in row 3 of the custom attribute table:

3: 0x06000007 (MethodDef)  0x06000004 (MethodDef)  01-00-01-00-00 (#350/78)           

Note that the EnCLog is in a kind of funny order (field attributes before method attributes?)

2f: 0x0c00001b (CustomAttribute)  0                          
30: 0x0c00001c (CustomAttribute)  0                          
31: 0x0c00001a (CustomAttribute)  0                          
32: 0x0c00001d (CustomAttribute)  0                          
33: 0x0c00001e (CustomAttribute)  0                          

Why it's a problem:

I think CoreCLR will accept this as is, but for Mono we expect row updates (like Gen 1 row 1) to have the same Parent as the previous generation, or to set the Parent to 0 (for a deletion). Updates (as opposed to row additions) shouldn't invalidate our assumption that all custom attributes for a given Parent are contiguous.

Metadata

Metadata

Assignees

No one assigned

    Labels

    untriagedIssues and PRs which have not yet been triaged by a lead

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions