← 输入框|github.com|刷新
Skip to content

Crashed when creating a DynamicData with struct containing getters in Mono #84

Open

Description

@WEGFan

Description

In mono, creating a DynamicData instance with a struct containing getters / properties will throw a System.InvalidProgramException.

MonoMod version: 21.8.19.1

Mono version:

$ mono --version
Mono JIT compiler version 6.8.0.105 (Debian 6.8.0.105+dfsg-2 Wed Feb 26 23:23:50 UTC 2020)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
        TLS:           __thread
        SIGSEGV:       altstack
        Notifications: epoll
        Architecture:  amd64
        Disabled:      none
        Misc:          softdebug
        Interpreter:   yes
        LLVM:          supported, not enabled.
        Suspend:       hybrid
        GC:            sgen (concurrent by default)

Example

This is compiled on Windows with target framework sets to 4.5.2, and ran with mono.

using MonoMod.Utils;

namespace ConsoleApp {
    public struct StructWithGetter {
        public int A => 1;

    }

    internal class Program {
        public static void Main(string[] args) {
            StructWithGetter obj = new StructWithGetter();
            DynamicData dynamicData = new DynamicData(obj);
        }
    }
}
System.InvalidProgramException: Invalid IL code in (wrapper dynamic-method) MonoMod.Utils.DynamicMethodDefinition:FastReflection<ConsoleApp.StructWithGetter::get_A> (object,object[]): IL_0006: call      0x00000003
  at (wrapper managed-to-native) System.Delegate.CreateDelegate_internal(System.Type,object,System.Reflection.MethodInfo,bool)
  at System.Delegate.CreateDelegate (System.Type type, System.Object firstArgument, System.Reflection.MethodInfo method, System.Boolean throwOnBindFailure, System.Boolean allowClosed) [0x00357] in <12b418a7818c4ca0893feeaaf67f1e7f>:0 
  at System.Delegate.CreateDelegate (System.Type type, System.Object firstArgument, System.Reflection.MethodInfo method) [0x00000] in <12b418a7818c4ca0893feeaaf67f1e7f>:0 
  at System.Reflection.Emit.DynamicMethod.CreateDelegate (System.Type delegateType, System.Object target) [0x0001d] in <12b418a7818c4ca0893feeaaf67f1e7f>:0 
  at MonoMod.Utils.Extensions.CreateDelegate (System.Reflection.MethodBase method, System.Type delegateType, System.Object target) [0x00027] in <59cbbd867fb04515abea4f0e92b83cc8>:0 
  at MonoMod.Utils.Extensions.CreateDelegate (System.Reflection.MethodBase method, System.Type delegateType) [0x00000] in <59cbbd867fb04515abea4f0e92b83cc8>:0 
  at MonoMod.Utils.FastReflectionHelper._CreateFastDelegate (System.Reflection.MethodBase method, System.Boolean directBoxValueAccess) [0x00284] in <59cbbd867fb04515abea4f0e92b83cc8>:0 
  at MonoMod.Utils.FastReflectionHelper.GetFastDelegate (System.Reflection.MethodInfo method, System.Boolean directBoxValueAccess) [0x00011] in <59cbbd867fb04515abea4f0e92b83cc8>:0 
  at MonoMod.Utils.DynamicData+_Cache_..ctor (System.Type targetType) [0x001c8] in <59cbbd867fb04515abea4f0e92b83cc8>:0 
  at MonoMod.Utils.DynamicData..ctor (System.Type type, System.Object obj, System.Boolean keepAlive) [0x00030] in <59cbbd867fb04515abea4f0e92b83cc8>:0 
  at MonoMod.Utils.DynamicData..ctor (System.Object obj) [0x00007] in <59cbbd867fb04515abea4f0e92b83cc8>:0 
  at ConsoleApp.Program.Main (System.String[] args) [0x00009] in <41ded9052c1e45cd9047475c53281ae4>:0 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions