[Mono-bugs] [Bug 551228] New: Race conditions despite locks with Mono 2.4 on IA-64 SGI Altix 4700

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Thu Oct 29 22:21:33 EDT 2009


http://bugzilla.novell.com/show_bug.cgi?id=551228


           Summary: Race conditions despite locks with Mono 2.4 on IA-64
                    SGI Altix 4700
    Classification: Mono
           Product: Mono: Runtime
           Version: unspecified
          Platform: IA64
        OS/Version: SuSE Linux 10.0
            Status: NEW
          Severity: Major
          Priority: P5 - None
         Component: misc
        AssignedTo: mono-bugs at lists.ximian.com
        ReportedBy: darryl at cain.com.au
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---


User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US)
AppleWebKit/532.0 (KHTML, like Gecko) Chrome/3.0.195.27 Safari/532.0

I am trying to get Mono 2.4 running on a SGI Altix 4700 (96-way Itanium 2
box) running SUSE Linux Enterprise Server 10.  It compiles successfully
using default configuration settings however upon testing (test program in
additional information) it fails at simple locking, that is, n threads
incrementing a shared counter produces race conditions.

I have tried;
 -> Changing "--with-tls" between both "__thread" and "pthread"
 -> Changing CFLAGS, CCASFLAGS, CXXFLAGS and FFLAGS to exclude
optimizations (removed -O2)
 -> Altering versions of glib (between glib-2.16.5 and glib-2.20.5) - there
is a gthread dependence but I am not sure how that impacts matters.

In addition the same behavior is present with Mono 1.2.2 (already on the
machine).  It should be noted that this test program works fine on a 8-way
AMD64 box producing correct results so I suspect it is something to do with the
IA-64 platform.

Reproducible: Always

Steps to Reproduce:
1. mono SharedCounter.exe 1000000 10

Actual Results:  
user at host:~/code/tests> mono SharedCounter.exe 1000000 10
1000000 increments over 10 threads
Counter value: 999023

user at host:~/code/tests> mono SharedCounter.exe 1000000 10
1000000 increments over 10 threads
Counter value: 999087

user at host:~/code/tests> mono SharedCounter.exe 1000000 10
1000000 increments over 10 threads
Counter value: 999211

user at host:~/code/tests> mono SharedCounter.exe 1000000 10
1000000 increments over 10 threads
Counter value: 999219

Expected Results:  
user at host:~/code/tests> mono SharedCounter.exe 1000000 10
1000000 increments over 10 threads
Counter value: 1000000

Using: glib-2.20.5, libunwind-0.99, gcc version 4.1.2 20070115 (SUSE
Linux)

Test Program:
----------------------------

using System;
using System.Threading;

namespace Test
{
  public class SharedCounter
  {
    private static int increments;
    private static int n_threads;

    private static object shared_lock = new object();
    private static int shared_counter = 0;

    public static void Main(string[] args)
    {
      if (args.Length < 2) {
        Console.WriteLine("Usage: SharedCounter.exe <increments> <threads>");
        return;
      }

      increments = Convert.ToInt32(args[0]);
      n_threads = Convert.ToInt32(args[1]);

      // Make equally distributed
      increments = (increments / n_threads) * n_threads;

      Console.WriteLine("{0} increments over {1} threads", increments,
n_threads);

      Thread[] threads = new Thread[n_threads];
      for (int i = 0; i < n_threads; i++)
      {
        threads[i] = new Thread(Worker);
      }

      for (int i = 0; i < n_threads; i++)
      {
        threads[i].Start();
      }

      for (int i = 0; i < n_threads; i++)
      {
        threads[i].Join();
      }

      Console.WriteLine("Counter value: {0}", shared_counter);
    }

    public static void Worker()
    {
      int steps = increments / n_threads;
      for (int i = 0; i < steps; i++)
      {
        lock (shared_lock)
        {
          shared_counter++;
        }
      }
    }
  }
}

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


More information about the mono-bugs mailing list