Bug 124 - recursive ReaderWriterLockSlim throws, invalid ctstate
Summary: recursive ReaderWriterLockSlim throws, invalid ctstate
Status: RESOLVED FIXED
Alias: None
Product: Class Libraries
Classification: Mono
Component: System.Core ()
Version: 2.10.x
Hardware: PC Linux
: --- major
Target Milestone: Untriaged
Assignee: Rodrigo Kumpera
URL:
Depends on:
Blocks:
 
Reported: 2011-07-31 11:01 UTC by Jakub Míšek
Modified: 2011-11-01 11:31 UTC (History)
6 users (show)

Tags: ReaderWriterLockSlim exception
Is this bug a regression?: ---
Last known good build:


Attachments
Test case (1.55 KB, text/plain)
2011-07-31 11:01 UTC, Jakub Míšek
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description Jakub Míšek 2011-07-31 11:01:16 UTC
Created attachment 41 [details]
Test case

ReaderWriterLockSlim(with LockRecursionPolicy.SupportsRecursion) throws an exception at:

Unhandled Exception: System.Threading.LockRecursionException: Exception of type 'System.Threading.LockRecursionException' was thrown.
  at System.Threading.ReaderWriterLockSlim.CheckRecursionAuthorization (LockState ctstate, LockState desiredState) [0x00007] in /usr/src/packages/BUILD/mono-2.10.2/mcs/class/System.Core/System.Threading/ReaderWriterLockSlim.cs:561 
  at System.Threading.ReaderWriterLockSlim.CheckState (System.Threading.ThreadLockState state, Int32 millisecondsTimeout, LockState validState) [0x00074] in /usr/src/packages/BUILD/mono-2.10.2/mcs/class/System.Core/System.Threading/ReaderWriterLockSlim.cs:552 
  at System.Threading.ReaderWriterLockSlim.TryEnterWriteLock (Int32 millisecondsTimeout) [0x00007] in /usr/src/packages/BUILD/mono-2.10.2/mcs/class/System.Core/System.Threading/ReaderWriterLockSlim.cs:235 
  at System.Threading.ReaderWriterLockSlim.EnterWriteLock () [0x00000] in /usr/src/packages/BUILD/mono-2.10.2/mcs/class/System.Core/System.Threading/ReaderWriterLockSlim.cs:228 



Seems to me, internal LockState is corrupted after
1.EnterWriteLock
2.  EnterUpgradeableReadLock
3.  ExitUpgradeableReadLock
4.ExitWriteLock

5.EnterWriteLock // causes the exception on Mono (.NET stays alive)
Comment 1 Jérémie Laval 2011-11-01 11:31:38 UTC
Fixed in master and mono-2-10. Thanks for the report!