runtime icon indicating copy to clipboard operation
runtime copied to clipboard

Exception handling not working well on non-Windows platforms in R2R

Open fadimounir opened this issue 10 years ago • 4 comments

The problem is when the exception is thrown from the DynamicHelperWorker API, used in R2R helper calls.

Minimal repro (crossgen binary before running it on Ubuntu):

public interface IUnimplemented { void UnimplementedMethod(); }

public class Castable : System.Runtime.CompilerServices.ICastable { public bool IsInstanceOfInterface(RuntimeTypeHandle interfaceType, out Exception castError) { castError = null; Console.WriteLine(String.Format("IsInstanceOfInterface has been called for type {0}", Type.GetTypeFromHandle(interfaceType))); return false; }

public RuntimeTypeHandle GetImplType(RuntimeTypeHandle interfaceType)
{
    Console.WriteLine(String.Format("GetImplType has been called for type {0}", Type.GetTypeFromHandle(interfaceType)));
    return this.GetType().TypeHandle;
}

}

public class Test { public static int Main(string[] args) { object implProxy = new Castable();

    try
    {
        var foo = (IUnimplemented)implProxy;
        Console.WriteLine("ERROR: CHKCAST didn't throw!!");
    }
    catch (InvalidCastException) 
    {
        Console.WriteLine("PASSED");
        return 100;
    }

    return -1;
}

}

fadimounir avatar Jun 03 '16 01:06 fadimounir

Fixed by dotnet/coreclr#5446

janvorli avatar Jun 03 '16 14:06 janvorli

@janvorli I am reopening this issue to track getting the fix into the release branch.

gkhanna79 avatar Jun 03 '16 14:06 gkhanna79

@gkhanna79 ok, makes sense.

janvorli avatar Jun 03 '16 14:06 janvorli

Fixed by https://github.com/dotnet/coreclr/pull/5461

sergiy-k avatar Jun 03 '16 16:06 sergiy-k