[Mono-bugs] [Bug 333342] New: mcs sets the synchronized flag on valuetype methods

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Fri Oct 12 07:10:31 EDT 2007


           Summary: mcs sets the synchronized flag on valuetype methods
           Product: Mono: Compilers
           Version: unspecified
          Platform: Other
        OS/Version: Other
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: C#
        AssignedTo: rharinath at novell.com
        ReportedBy: lupus at novell.com
         QAContact: mono-bugs at ximian.com
          Found By: ---

>From the ECMA spec:
It makes no sense for ValueTypes, which have no identity, to have synchronized
methods (unless they are boxed). So, if the owner of this method is a ValueType
then the method cannot be synchronized. That is, ImplFlags.Synchronized shall
be 0 [ERROR]
See how this test is compiled:
struct T {
        public delegate void Do ();
        public event Do MyDo2;
        static void Main () {
                T t = new T ();
                B.test (ref t);
                t.MyDo2 ();

class B {
        static void p () {System.Console.WriteLine ("hi2");}
        public static void test (ref T t) {
                t.MyDo2 += p;

The mono runtime will generate an exception in the synch wrapper we use
because mcs sets the synchronized flag on the add/remove event methods.

This program is also compiled:
using System.Runtime.CompilerServices;

struct Test {

        public int test () {
                return 2 + 2;

        static public int Main (string[] args) {
                Test b = new Test ();
                int res = b.test ();

                return 0;

Note: I haven't tested if this compiles with csc or if the MS runtime ignores
the flag or reports the error. For the first test case the mcs-compiled binary
causes a TypeLoad exception to be thrown by the MS runtime.

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