summaryrefslogtreecommitdiff
path: root/tests/src/Regressions/coreclr/GitHub_12224/test12224.cs
blob: 8a3124c1b832916446e55894c2b31dfa5d5cabc2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Threading;

public class Test12224
{    
    // Regression test for EH getting stuck in an infinite loop when NullReferenceException
    // happens inside a handler of another NullReferenceException.
    static void ExecuteTest(object context)
    {
        string s = null;
        try
        {
            try
            {
                int x = s.Length;
            }
            catch (NullReferenceException)
            {
                int x = s.Length;
            }
        }
        catch (NullReferenceException)
        {

        }
    }

    public static int Main()
    {
        Thread thread = new Thread(new ParameterizedThreadStart(Test12224.ExecuteTest));
        thread.IsBackground = true;
        thread.Start(null);

        // Give the thread 30 seconds to complete (it should be immediate). If it fails
        // to complete within that timeout, it has hung.
        bool terminated = thread.Join(new TimeSpan(0, 0, 30));

        return terminated ? 100 : -1;
    }
}