[Mono-bugs] [Bug 80102][Maj] New - [PATCH] Novell.Directory.Ldap.Connection deadlock in finalizer

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Thu Nov 30 15:10:26 EST 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 jlarimer at gmail.com.

http://bugzilla.ximian.com/show_bug.cgi?id=80102

--- shadow/80102	2006-11-30 15:10:26.000000000 -0500
+++ shadow/80102.tmp.4417	2006-11-30 15:10:26.000000000 -0500
@@ -0,0 +1,88 @@
+Bug#: 80102
+Product: Mono: Class Libraries
+Version: 1.2
+OS: 
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Major
+Component: System
+AssignedTo: mono-bugs at ximian.com                            
+ReportedBy: jlarimer at gmail.com               
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: [PATCH] Novell.Directory.Ldap.Connection deadlock in finalizer
+
+Description of Problem:
+
+   If there is an exception while connecting in 
+Novell.Directory.Ldap.Connection.connect(), the writeSemaphore is not 
+released. When the Connection is later finalized and shutdown() is called, 
+shutdown() will not be able to acquire the semaphore and the Mono 
+finalizer thread will hang forever, causing all sorts of problems.
+
+Steps to reproduce the problem:
+
+----8<---------
+
+using System;
+using System.Collections;
+using System.Collections.Specialized;
+using System.DirectoryServices;
+
+class Test {
+    static void Main(string[] args) {
+        try {
+            TestLdap tl = new TestLdap();
+            tl.DoLdap();
+        } catch (Exception e) {
+            Console.WriteLine("{0}", e.Message);
+        }
+
+        Console.WriteLine("Collecting garbage");
+
+        // force collection
+        GC.Collect();
+        GC.WaitForPendingFinalizers();
+
+        Console.WriteLine("Done");
+
+    }
+}
+
+class TestLdap {
+    public void DoLdap() {
+        DirectoryEntry de = new DirectoryEntry("LDAP://localhost", "", "", 
+AuthenticationTypes.ServerBind);
+        using(DirectorySearcher ds = new DirectorySearcher(de)) {
+            ds.FindAll();
+        }
+        de.Close();
+    }
+}
+
+----8<---------
+
+Compile above program with "mcs LdapTest.cs -
+r:System.DirectoryServices.dll". Run LdapTest.exe and it will hang, unless 
+localhost is running an LDAP server.
+
+Actual Results:
+
+   Above program hangs forever.
+
+Expected Results:
+
+   Above program should not hang forever.
+
+How often does this happen? 
+
+   Every time.
+
+Additional Information:
+
+Attaching a proposed patch which uses a try/finally block to release the 
+semaphore in connect().


More information about the mono-bugs mailing list