[Mono-bugs] [Bug 662381] C# lock () fails on latest Mono runtimes

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Wed Jan 5 08:40:08 EST 2011



Jérémie LAVAL <jeremie.laval at gmail.com> changed:

           What    |Removed                     |Added
             Status|NEW                         |CLOSED
            Version|2.8.x                       |SVN
          Component|misc                        |CORLIB
         AssignedTo|jeremie.laval at gmail.com     |mono-bugs at lists.ximian.com
         Resolution|                            |FEATURE
   Target Milestone|---                         |SVN
            Product|Mono: Runtime               |Mono: Class Libraries
           Severity|Critical                    |Enhancement

--- Comment #4 from Jérémie LAVAL <jeremie.laval at gmail.com> 2011-01-05 13:40:07 UTC ---

TPL scheduler in Mono by default use a Wait mechanism that is cooperating,
trying to execute other waiting task to prevent deadlocking. 

A consequence is that TPL threads are reused to execute nested Parallel.For
loops and since lock is re-entrant your problem occur.

It's rather difficult to change that behavior and it has proven to improve
robustness so I would rather leave it like this. 

To fix your code you have a couple of possibilities: remove lock and use
ConcurrentDictionary, use a non re-entrant lock (SpinLock could do or
alternatively Rwls), detect and prevent nested execution of Parallel.For or use
a custom scheduler.

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