runtime: EnC: ExecutionEngineException after edit in struct returning method

Version:

CoreCLR 3.1 and Desktop CLR 4.7.1

Steps to Reproduce:

namespace DebuggerTest
{
    public class GenericStructReturn
    {
        public static void Main() { System.Console.WriteLine(F()); }
        public static S<object, object> F()
        {
            return new S<object, object>("Hello", "");   // Breakpoint on this line
        }
    }

    public struct S<T1, T2>
    {
        private T1 o1;
        private T2 o2;

        public S(T1 o1, T2 o2)
        {
            this.o1 = o1;
            this.o2 = o2;
        }

        public override string ToString()
        {
            return o1 + " " + o2;
        }
    }
}
  1. In the code above, place a breakpoint inside the F() method
  2. F5
  3. When the breakpoint is hit, put a string in for the second constructor parameter
  4. F5
  5. Observe the crash

Looked into it from the Roslyn side and seems to be a CLR bug.

From feedback ticket https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1246874 /cc @tmat

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 26 (23 by maintainers)

Most upvoted comments

Having looked at this issue on the back of a StackOverflow question, it appears to result from varNumber not being treated as a signed value when indexing into oldMethodVarsSorted/newMethodVarsSorted.

As a result, for special vars with negative varNumbers, instead of placing them in the space reserved at the beginning of the corresponding oldMethodVarsSortedBase/newMethodVarsSortedBase arrays for special vars, it is treated as a large positive index way off the end of the array.

Hope this helps.

If this bug is at all representative of a broader desire to use Hot Reload as a time to revisit pre-existing EnC bugs and fix them thats probably a good discussion to have

I expect there will be others. 😉

cc: @danroth27, @LyalinDotCom

I don’t understand why the fact that it reproes on desktop has any impact on scheduling of the fix. We are spending a lot of effort on improving EnC/Hot Reload experience for .NET 6. This issue is relevant to this effort.

The method being modified is not generic. This should be supported.