[Mono-bugs] [Bug 483113] New: Monitor.Exit does not throw SynchronizationLockException if object is not locked.

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Fri Mar 6 19:35:52 EST 2009


           Summary: Monitor.Exit does not throw
                    SynchronizationLockException if object is not locked.
    Classification: Mono
           Product: Mono: Runtime
           Version: 2.2.x
          Platform: x86-64
        OS/Version: All
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: misc
        AssignedTo: mono-bugs at lists.ximian.com
        ReportedBy: ravitch at nrtc.northrop.com
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---

Created an attachment (id=277817)
 --> (https://bugzilla.novell.com/attachment.cgi?id=277817)
Test case

User-Agent:       Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:
Gecko/2009020911 Ubuntu/8.10 (intrepid) Firefox/3.0.6

In MS .Net 2.0, calling Monitor.Exit() when there has not been a corresponding
call to Monitor.Enter() (or use of the lock primitive) causes a
System.Threading.SynchronizationLockException to be thrown.  Mono does not do

Just poking around, it looks like the problem is in mono/metadata/monitor.c:658
which looks like:

if (G_UNLIKELY (mon == NULL)) {
    /* No one ever used Enter. Just ignore the Exit request as MS does */

(Perhaps .Net 1.1 behaved this way - but for at least 2.0, it's no longer the
case that MS just ignores the Exit request.)

Reproducible: Always

Steps to Reproduce:
1. Compile attached example code (either with gmcs or csc)
2. Run the resulting assembly.
Actual Results:  
[Exits silently.]

Expected Results:  
Unhandled Exception: System.Threading.SynchronizationLockException: Object
synchronization method was called from an unsynchronized block of code.
   at LockTest.Main()

Configure bugmail: https://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