Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash when using Delegate.CreateDelegate with DynamicMethod #8543

Open
joncham opened this issue May 2, 2018 · 1 comment
Open

Crash when using Delegate.CreateDelegate with DynamicMethod #8543

joncham opened this issue May 2, 2018 · 1 comment

Comments

@joncham
Copy link
Contributor

joncham commented May 2, 2018

Steps to Reproduce

  1. Run attached test case below
using System;
using System.Reflection.Emit;

internal class Program
{
    public static int Main()
    {
        var methodBuilder = new DynamicMethod("test", typeof(void), new Type[0], typeof(Program).Module);
        Delegate.CreateDelegate(typeof(Action), methodBuilder);

        return 0;
    }
}

Current Behavior

Crash!!!

Expected Behavior

.NET gives:

Unhandled Exception: System.ArgumentException: MethodInfo must be a RuntimeMethodInfo.
Parameter name: method
   at System.Delegate.CreateDelegate(Type type, MethodInfo method, Boolean throwOnBindFailure)
   at Program.Main()

On which platforms did you notice this

[ ] macOS
[ ] Linux
[ ] Windows

Version Used:

Mono JIT compiler version 5.11.0 (Visual Studio built mono)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
        TLS:           normal
        SIGSEGV:       normal
        Notification:  Thread + polling
        Architecture:  x86
        Disabled:      none
        Misc:          softdebug
        Interpreter:   yes
        LLVM:          supported, not enabled.
        GC:            sgen (concurrent by default)

Stacktrace

 	mono.dll!mono_method_signature(_MonoMethod * m) Line 2165	C
>	mono.dll!ves_icall_System_Delegate_CreateDelegate_internal(_MonoReflectionType * type, MonoObject * target, _MonoReflectionMethod * info, unsigned char throwOnBindFailure) Line 5686	C
@joncham
Copy link
Contributor Author

joncham commented May 3, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants