diff options
author | Mark Probst <mark.probst@gmail.com> | 2012-11-29 20:35:34 +0400 |
---|---|---|
committer | Mark Probst <mark.probst@gmail.com> | 2012-11-29 20:35:34 +0400 |
commit | 777de937b654c011b0ad7573cfe7b8c1bc8662d2 (patch) | |
tree | 23286487734f69e0e3a537d2c3a2b375dec20660 | |
parent | 72ebeab25bc1924b7a191a3c59436728d74f6cdb (diff) |
[tests] Fix pinning in finalizer-exception.cs.
The finalizable object got pinned, so it wouldn't be finalised. Just
recurse a bit and allocate it there.
-rw-r--r-- | mono/tests/finalizer-exception.cs | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/mono/tests/finalizer-exception.cs b/mono/tests/finalizer-exception.cs index d11e1696f14..1496dc54b47 100644 --- a/mono/tests/finalizer-exception.cs +++ b/mono/tests/finalizer-exception.cs @@ -6,13 +6,25 @@ public class FinalizerException { throw new Exception (); } + /* + * We allocate the exception object deep down the stack so + * that it doesn't get pinned. + */ + public static void MakeException (int depth) { + if (depth <= 0) { + new FinalizerException (); + return; + } + MakeException (depth - 1); + } + public static int Main () { AppDomain.CurrentDomain.UnhandledException += (sender, args) => { Console.WriteLine ("caught"); Environment.Exit (0); }; - new FinalizerException (); + MakeException (100); GC.Collect (); GC.WaitForPendingFinalizers (); |