[Mono-bugs] [Bug 78633][Cri] New - Serious bug in lock - locks not
unlocked on exception
bugzilla-daemon at bugzilla.ximian.com
bugzilla-daemon at bugzilla.ximian.com
Tue Jun 13 12:27:11 EDT 2006
Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.
Changed by vargaz at gmail.com.
http://bugzilla.ximian.com/show_bug.cgi?id=78633
--- shadow/78633 2006-06-13 12:27:11.000000000 -0400
+++ shadow/78633.tmp.13049 2006-06-13 12:27:11.000000000 -0400
@@ -0,0 +1,122 @@
+Bug#: 78633
+Product: Mono: Runtime
+Version: 1.1
+OS: other
+OS Details: CentOS 4
+Status: RESOLVED
+Resolution: FIXED
+Severity: Unknown
+Priority: Critical
+Component: misc
+AssignedTo: mono-bugs at ximian.com
+ReportedBy: nikki at trumphurst.com
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL:
+Cc:
+Summary: Serious bug in lock - locks not unlocked on exception
+
+Please fill in this template when reporting a bug, unless you know what
+you are doing.
+Description of Problem:
+
+It is possible to execute code which throws an Exception inside a lock
+statement which exits the statement without releasing the lock.
+Steps to reproduce the problem:
+1. Compile attached code with mcs -codepage:1252 -optimize- -delaysign- -
+target:winexe -r:"System.dll" -r:"System.Data.dll" Test.cs
+
+2. Run with mono Test.exe
+
+Actual Results:
+Error thread initial sleep
+Main thread initial sleep
+Returning null from NextError
+Trying
+Trying to lock error -1090733248
+Returning null from NextError
+Returning null from NextError
+Returning null from NextError
+Returning null from NextError
+Returning null from NextError
+Returning null from NextError
+Returning null from NextError
+Returning null from NextError
+Returning null from NextError
+Error thread exiting
+[program now hangs forever, waiting for the lock]
+
+Expected Results:
+Main thread obtains lock and program exits normally.
+
+How often does this happen?
+Every time
+
+Additional Information:
+Here is the code to reproduce the problem...
+
+using System;
+using System.Threading;
+
+namespace SpecSoft.Lib {
+
+ public class Test {
+
+ private static Object _error = new Object();
+
+ public static void Main() {
+ Thread _errorThread = new Thread(new ThreadStart
+(errorThread));
+
+ _errorThread.IsBackground = true;
+ _errorThread.Name = "Error reporting thread";
+ _errorThread.Start();
+ System.Console.WriteLine("Main thread initial
+sleep");
+ Thread.Sleep(2000);
+ System.Console.WriteLine("Trying");
+ System.Console.WriteLine("Trying to lock error
+{0}", _error.GetHashCode());
+ lock(_error) {
+ System.Console.WriteLine("Locked error");
+ }
+ System.Console.WriteLine("Unlocked error");
+ }
+
+ private static void errorThread() {
+ System.Console.WriteLine("Error thread initial
+sleep");
+ Thread.Sleep(1000);
+ for(int i = 0; i < 10; i++) {
+ NextError();
+ Thread.Sleep(1000);
+ }
+ System.Console.WriteLine("Error thread exiting");
+ }
+
+ public static string NextError() {
+ try {
+ lock(_error) {
+ string [] files = new string[1];
+
+ return files[2];
+ // Throws an exception
+ }
+ } catch {
+ }
+ System.Console.WriteLine("Returning null from
+NextError");
+ return null;
+ }
+
+ }
+}
+
+------- Additional Comments From nikki at trumphurst.com 2006-06-13 10:44 -------
+The problem goes away if you change the empty catch statement in
+NextError from "} catch {" to "} catch(Exception ex) {", so maybe
+the bug is in the compiler?
+
+------- Additional Comments From vargaz at gmail.com 2006-06-13 12:27 -------
+Fixed in SVN.
+
More information about the mono-bugs
mailing list