Created
March 4, 2019 15:23
-
-
Save janvorli/c4b69292d1404a5f6a45340e41739c39 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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