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

[release/8.0.1xx-xcode15.1] [Blocks] Remove a block callback validation that's apparently too eager. #20700

Commits on Jun 7, 2024

  1. [Blocks] Remove a block callback validation that's apparently too eager.

    The validation verifies that the function pointer for a block callback is the
    same the return value from the method's
    MethodInfo.MethodHandle.GetFunctionPointer() method.
    
    In actual code, it's equivalent to validating that the following always prints "Equal: true":
    
    ```cs
    [UnmanagedCallersOnly]
    public static void Invoke () {}
    
    static void Test ()
    {
        delegate* unmanaged<void> fptr1 = &Invoke;
        IntPtr fptr2 = GetType ().GetMethod ("Invoke").MethodHandle.GetFunctionPointer ();
        Console.WriteLine ($"fptr1: 0x{((IntPtr) fptr1).ToString ("x")}");
        Console.WriteLine ($"fptr2: 0x{fptr2.ToString ("x")}");
        Console.WriteLine ($"Equal: ((IntPtr) fptr1) == fptr2}"); // prints "Equal: true" for me
    }
    ```
    
    However, this isn't documented, and some feedback indicates it's certainly not
    a valid assumption for CoreCLR:
    
    https://discord.com/channels/732297728826277939/732582981163548703/1242473425759633488
    
    And there's also a customer running into this validation, apparently withou cause:
    https://devdiv.visualstudio.com/DevDiv/_workitems/edit/2054534
    
    So just remove it.
    rolfbjarne authored and vs-mobiletools-engineering-service2 committed Jun 7, 2024
    Configuration menu
    Copy the full SHA
    c5f4e06 View commit details
    Browse the repository at this point in the history