[Mono-bugs] [Bug 465377] New: Mono throws TypeLoadException due to some race condition

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Mon Jan 12 09:31:13 EST 2009


https://bugzilla.novell.com/show_bug.cgi?id=465377


           Summary: Mono throws TypeLoadException due to some race
                    condition
    Classification: Mono
           Product: Mono: Runtime
           Version: SVN
          Platform: Other
        OS/Version: Other
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: JIT
        AssignedTo: mprobst at novell.com
        ReportedBy: mprobst at novell.com
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---


Running this program sometimes results in TypeLoadExceptions in the two
threads:

using System;
using System.Threading;
using System.Runtime.CompilerServices;

public class main {
    [MethodImplAttribute(MethodImplOptions.Synchronized)]
    public static void thread_func () {
    }

    public static int Main () {
    Thread t1 = new Thread (new ThreadStart (thread_func));
    Thread t2 = new Thread (new ThreadStart (thread_func));

    t1.Start ();
    t2.Start ();

    t1.Join ();
    t2.Join ();

    return 0;
    }
}

On my x86 machine that happens about once out of every 200 runs.  On PPC64 this
program makes it happen much more frequently (around once out of every 5 runs):

using System;
using System.Threading;
using System.Runtime.CompilerServices;

public class main {
    static int global = 0;
    static Random random = new Random ();

    public static int fib (int i) {
    if (i < 2)
        return i;
    return fib (i - 2) + fib (i - 1);
    }

    [MethodImplAttribute(MethodImplOptions.Synchronized)]
    public static bool synch () {
    if (global != 0)
        return false;
    global = 1;
    fib (random.Next (5, 12));
    global = 0;
    return true;
    }

    public static void thread_func () {
    int i;

    for (i = 0; i < 1000; ++i)
        if (!synch ()) {
        Console.WriteLine ("fail");
        Environment.Exit (1);
        }
    }

    public static int Main () {
    Thread t1 = new Thread (new ThreadStart (thread_func));
    Thread t2 = new Thread (new ThreadStart (thread_func));

    Console.WriteLine ("starting");

    t1.Start ();
    t2.Start ();

    t1.Join ();
    t2.Join ();

    return 0;
    }
}

-- 
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.


More information about the mono-bugs mailing list