Bug 31711 - When running application that's accessing Active Directory/LDAP multiple times - receive System.ObjectDisposedException
Summary: When running application that's accessing Active Directory/LDAP multiple time...
Status: NEW
Alias: None
Product: Class Libraries
Classification: Mono
Component: General (show other bugs)
Version: 4.0.0
Hardware: PC Linux
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2015-07-07 11:49 UTC by stanislav.yeshchenko
Modified: 2016-06-06 10:13 UTC (History)
2 users (show)

See Also:
Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
c sharp file and dll reference to be compiled (26.63 KB, application/x-zip-compressed)
2015-07-07 11:49 UTC, stanislav.yeshchenko
Details

Description stanislav.yeshchenko 2015-07-07 11:49:02 UTC
Created attachment 11910 [details]
c sharp file and dll reference to be compiled

Overview: 

I created a simple C# library that will login a user into Active Directory and check if user is a member of a specific group.  

Running this application with mono on Linux Ubuntu 14.04 usually works fine for the first time, but after running it multiple times I receive: 

Unhandled Exception:
System.ObjectDisposedException: The object was used after being disposed.
  at System.Net.Sockets.NetworkStream.CheckDisposed () [0x00000] in <filename unknown>:0 
  at System.Net.Sockets.NetworkStream.Read (System.Byte[] buffer, Int32 offset, Int32 size) [0x00000] in <filename unknown>:0 
  at System.IO.Stream.ReadByte () [0x00000] in <filename unknown>:0 
  at Novell.Directory.Ldap.Asn1.Asn1Identifier..ctor (System.IO.Stream in_Renamed) [0x00000] in <filename unknown>:0 
  at Novell.Directory.Ldap.Connection+ReaderThread.Run () [0x00000] in <filename unknown>:0 
  at System.Threading.Thread.StartInternal () [0x00000] in <filename unknown>:0 
[ERROR] FATAL UNHANDLED EXCEPTION: Nested exception detected.
Original Exception: at System.Net.Sockets.NetworkStream.CheckDisposed () <IL 0x0001d, 0x00047>
at System.Net.Sockets.NetworkStream.Read (byte[],int,int) <IL 0x00001, 0x00037>
at System.IO.Stream.ReadByte () <0x0003d>
at Novell.Directory.Ldap.Asn1.Asn1Identifier..ctor (System.IO.Stream) <IL 0x00007, 0x00023>
at Novell.Directory.Ldap.Connection/ReaderThread.Run () <IL 0x0003c, 0x0019b>
at System.Threading.Thread.StartInternal () <0x000c2>

Running this application with mono on Windows7 works as expected. 

Steps to Reproduce: 

1) Unpack attached compressed file, open Program.cs, search for TODO and update fields with your own information e.g. LDAP server address, username, password. 

2) Compile using: csc.exe Program.cs /r:System.DirectoryServices.AccountManagement.dll

3) Run Program.exe on Ubuntu 14.04

Actual Results: Application may work as expected for the first few times, but after running for multiple times exception described above is thrown. 

Expected Results: Application should not be crashing even after running for multiple times

Build Date & Platform: 07/07/2014 Windows7 x64

Additional Builds and Platforms: 

Only occurs in Linux

Additional information: 

From my understanding it looks like something in Novell.Directory.Ldap namespace is not getting properly disposed on application exit.
Comment 1 xamarin 2016-06-06 10:13:31 UTC
Hi Stanislav,

did you ever get any further information about this error? I currently struggle with a closed source mono-software, which give exactly this error maybe every 50th ldap-connect.

Note You need to log in before you can comment on or make changes to this bug.