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

[ARM/Linux] Core CLR failed to propagate exception through unmanged-managed boundary #6820

Closed
parjong opened this issue Oct 17, 2016 · 0 comments

Comments

@parjong
Copy link
Contributor

parjong commented Oct 17, 2016

In ARM/Linux, Core CLR failed to propagate exception through unmanaged-managed boundary.

As a result, Core CLR does not work as expected for the following code:

  • Framework.c
typedef void (*func_t)(int);

void Run(func_t func)
{
  func(3);
}
  • Program.cs
using System;
using System.Runtime.InteropServices;

namespace ConsoleApplication
{
  public class Program
  {
    public delegate void Callback(int n);

    [DllImport("Framework")]
    public static extern void Run(Callback cb);

    private static void Process(int num)
    {
      throw new System.ArgumentException("Invalid argument " + num);
    }

    public  static void Main(string[] args)
    {
      Console.WriteLine("Before");
      try
      {
        Run(Process);
      }
      catch (System.Exception ex)
      {
        Console.WriteLine("Caught");
        Console.WriteLine(ex);
      }
      Console.WriteLine("After");
    }
  }
}

The exception is expected to be caught in Main, but it doesn't:

Before

Unhandled Exception: System.ArgumentException: Invalid argument 3
   at ConsoleApplication.Program.Process(Int32 num)
   at ConsoleApplication.Program.Run(Callback cb)
   at ConsoleApplication.Program.Main(String[] args)
@parjong parjong closed this as completed Nov 11, 2016
@msftgits msftgits transferred this issue from dotnet/coreclr Jan 31, 2020
@ghost ghost locked as resolved and limited conversation to collaborators Dec 28, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant