Open
Description
Description
Run the test application below on a Windows X86 build of the runtime
Reproduction Steps
using System.Runtime.CompilerServices;
namespace TestThrowExceptionAcrossStaticMethodOnCanonGenericType
{
internal class Program
{
[MethodImpl(MethodImplOptions.NoInlining)]
static void Throw()
{
throw new NotSupportedException();
}
class Test<T>
{
[MethodImpl(MethodImplOptions.Synchronized | MethodImplOptions.NoInlining)]
public static void CallThrow()
{
Throw();
}
}
static void ThrowAndCatchEHThroughSharedGenericSyncrhonizedMethod()
{
try
{
Test<object>.CallThrow();
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
}
static void Main(string[] args)
{
Thread thread = new Thread(ThrowAndCatchEHThroughSharedGenericSyncrhonizedMethod);
thread.Start();
thread.Join();
ThrowAndCatchEHThroughSharedGenericSyncrhonizedMethod();
Console.WriteLine("Passed!");
}
}
}
Expected behavior
Program should complete
Actual behavior
Program deadlocks
Regression?
Not a regression. Likely broken since .NET 2.0
Known Workarounds
Instead of implementing the method as a synchronized method, use a lock on the typeof the Type object of the method's containing type.
Configuration
Windows X86
Other information
No response
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment