Skip to content

Support for reflection-invoking methods that take pointers by reference #10842

@MichalStrehovsky

Description

@MichalStrehovsky

dotnet/coreclr#17732 added support for reflection-invoking methods that return unmanaged pointers by reference (so e.g. ref void* Do()), but methods that get them by-reference as their parameters are still pretty broken (so e.g. void Do(ref void* x)).

For example:

using System;
using System.Reflection;

unsafe class Program
{
    public static void InvokeMe(out int* pointer)
    {
        pointer = (int*)0x12345;
    }

    static void Main(string[] args)
    {
        typeof(Program).GetMethod(nameof(InvokeMe)).Invoke(null, new object[] { null });
    }
}

Will crash the runtime with an ExecutionEngineException.

(Note this behavior is on parity with the desktop CLR, so it has quite likely been this broken for 17 years.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-System.ReflectionenhancementProduct code improvement that does NOT require public API changes/additions

    Type

    No type

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions