Skip to content

Instantly share code, notes, and snippets.

@janvorli
Created March 4, 2019 15:23
Show Gist options
  • Save janvorli/c4b69292d1404a5f6a45340e41739c39 to your computer and use it in GitHub Desktop.
Save janvorli/c4b69292d1404a5f6a45340e41739c39 to your computer and use it in GitHub Desktop.
// 100% repro of the #22820 on x86 when running with env var COMPlus_GCStress=4
using System;
namespace SimpleAyendeRepro
{
class DisposableObject : IDisposable
{
public void Dispose()
{
Console.WriteLine("In dispose");
}
}
class Program
{
public static bool IsExpectedException(Exception e)
{
Console.WriteLine("In filter");
GC.Collect();
return e is OperationCanceledException;
}
public static IDisposable AllocateObject()
{
return new DisposableObject();
}
static void Main(string[] args)
{
try
{
try
{
using (AllocateObject())
{
throw new Exception();
}
}
catch (Exception e1) when (IsExpectedException(e1))
{
Console.WriteLine("In catch 1");
}
}
catch (Exception e2)
{
Console.WriteLine("In catch 2");
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment