[Mono-dev] Ldap and Threading

Konstantin Triger kostat at mainsoft.com
Thu Jan 26 07:31:53 EST 2006


Hello Mike,

First, I run the test you provided both on mono (r55426) and on .net 1.1
runtime (using slightly changed Novell.Directory.Ldap assembly). I
addressed the functionality aspect only and did not measure/optimize for
performance.

Here are my findings:

1. .Net always succeeded to finish with no exceptions.
2. Mono sometimes failed on cygwin with problems in GC.

------------------------------------------------------------------------
---

I analyzed the exceptions reported:

1. Unhandled Exception: System.ArgumentException: length in <0x005cc>
System.Array:Copy (System.Array sourceArray, Int32 sourceIndex,
System.Array destinationArray, Int32 destinationIndex, Int32 length) in
<0x0004b> System.Array:Copy (System.Array sourceArray, System.Array
destinationArray, Int32 length) in <0x00016>
System.Collections.ArrayList:CopyTo (System.Array array) in <0x0002a>
System.Collections.ArrayList:ToArray () in <0x00048>
Novell.Directory.Ldap.MessageVector:findMessageById (Int32
msgId)
in <0x001a7> Novell.Directory.Ldap.Connection+ReaderThread:Run () in
(wrapper delegate-invoke) System.MulticastDelegate:invoke_void ()

Looking into MessageVector:findMessageById: this exception can ever
happen if someone alters the ArrayList from another thread. In order to
solve this bug we need to identify the race condition and cure it (for
example, by locking). Since reproducer is very environment specific, I
will really appreciate if you will try to identify the synchronization
hole.

2. Unhandled Exception: System.SystemException: Internal error, cannot
create
clone: Thread was being aborted
in <0x0007b> Novell.Directory.Ldap.Asn1.Asn1Identifier:Clone () in
<0x00230> Novell.Directory.Ldap.Asn1.LBERDecoder:decode
(System.IO.Stream in_Renamed, System.Int32[] len) in <0x0004d>
Novell.Directory.Ldap.Asn1.Asn1Structured:decodeStructured
(Asn1Decoder dec, System.IO.Stream in_Renamed, Int32 len) in <0x00023>
Novell.Directory.Ldap.Asn1.Asn1Sequence:.ctor (Asn1Decoder dec,
System.IO.Stream in_Renamed, Int32 len) in <0x00041>
Novell.Directory.Ldap.Rfc2251.RfcLdapMessage:.ctor (Asn1Decoder dec,
System.IO.Stream in_Renamed, Int32 len) in <0x0017d>
Novell.Directory.Ldap.Connection+ReaderThread:Run () in (wrapper
delegate-invoke) System.MulticastDelegate:invoke_void ()

As I understand, this is a runtime issue: when a thread is aborted, the
exception thrown should always be the ThreadAbortedException. If you
experience this, please file a bug for mscorlib.

3. Unhandled Exception: System.IndexOutOfRangeException: Asn1Structured:
set:
index 1, size 1
in <0x00107> Novell.Directory.Ldap.Asn1.Asn1Structured:get_Renamed
(Int32
index)
in <0x0004c> Novell.Directory.Ldap.Rfc2251.RfcLdapMessage:.ctor
(Asn1Decoder dec, System.IO.Stream in_Renamed, Int32 len) in <0x0017d>
Novell.Directory.Ldap.Connection+ReaderThread:Run () in (wrapper
delegate-invoke) System.MulticastDelegate:invoke_void ()

Same like in first exception - race which should be identified.

------------------------------------------------------------------------
---

I looked into the BoiledDown patch, here are my comments:

1. '\n' -> Environment.NewLine changes. Can you provide some
explanations / test case(s) for this?
2. The rest of the patch deals with correct catching and passing of the
exceptions thrown in the "working" thread to the "user" thread. This
definitely solves the "hang" issue, but does nothing with the cause of
those exceptions. So the route bug(s) remain (correct me if I'm wrong). 


Regards,
Konstantin Triger


-----Original Message-----
From: Mike Glenn [mailto:mglenn at zoominternet.net] 
Sent: Thursday, January 19, 2006 9:27 PM
To: Konstantin Triger
Cc: mono-devel-list at lists.ximian.com
Subject: RE: [Mono-dev] Ldap and Threading

> If you can send to this forum just the relevant diffs 
> (patches) and, if
> possible, provide a brief explanation about the changes, I 
> will be glad to look into them.
 
Ok I've included two different patches. The Full_Novell one is a
complete diff
based on the code that JD provided to me, so that you can have a base of
what
was provided to me. The second BoiledDown patch contains what I'm fairly
certain
are the relevant fixes (If I wasn't sure I used JD's changes). The
changes
appear to be mainly in what objects are used for locking and the scope
of the
locking, a new threading class, as well as some more extensive exception
handling. Which makes sense as that's the issues I was having with the
lib. 

If more detailed explanations are needed I'm afraid we'll have to hope
that JD
is still reading the list and can respond.

Mike Glenn




More information about the Mono-devel-list mailing list