Bug 39626 - Legacy code: handshake hangs indefinitely
Summary: Legacy code: handshake hangs indefinitely
Status: RESOLVED NORESPONSE
Alias: None
Product: Class Libraries
Classification: Mono
Component: Mono.Security ()
Version: 4.0.0
Hardware: PC Mac OS
: Normal normal
Target Milestone: Untriaged
Assignee: Martin Baulig
URL:
Depends on:
Blocks:
 
Reported: 2016-03-15 02:51 UTC by Manuel Sugawara
Modified: 2018-03-13 11:07 UTC (History)
4 users (show)

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


Attachments
Test case. (104.54 KB, application/x-bzip2)
2016-03-15 02:51 UTC, Manuel Sugawara
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 NORESPONSE

Description Manuel Sugawara 2016-03-15 02:51:14 UTC
Created attachment 15402 [details]
Test case.

We have a LDAP server sitting behind haproxy. If the LDAP server is down, due the delay response of haproxy, the ssl handshake hangs indefinitely waiting on a connection that's already closed. This causes the mono process to suck up 100% of the CPU. I've been able to reproduce this in Linux and Mac with mono 4.0 and mono 3.2. I haven't test with mono 4.4. Attached is a test case, just start the BadServer.exe and in another terminal try to connect using ConnectLdap.exe. The thread dump looks like:

Full thread dump:

"Threadpool worker"  at <unknown> <0xffffffff>
  at (wrapper managed-to-native) object.__icall_wrapper_mono_delegate_begin_invoke (object,intptr) <0xffffffff>
  at (wrapper delegate-begin-invoke) <Module>.begin_invoke_IAsyncResult__this___IAsyncResult_AsyncCallback_object (System.IAsyncResult,System.AsyncCallback,object) <0xffffffff>
  at Mono.Security.Protocol.Tls.RecordProtocol/ReceiveRecordAsyncResult.SetComplete (System.Exception,byte[]) <0x000cf>
  at Mono.Security.Protocol.Tls.RecordProtocol/ReceiveRecordAsyncResult.SetComplete (byte[]) <0x0001f>
  at Mono.Security.Protocol.Tls.RecordProtocol.InternalReceiveRecordCallback (System.IAsyncResult) <0x0008f>
  at (wrapper runtime-invoke) <Module>.runtime_invoke_void__this___object (object,intptr,intptr,intptr) <0xffffffff>

"IO Threadpool worker"
"Threadpool worker"
"Threadpool worker"
"<unnamed thread>"  at <unknown> <0xffffffff>
  at (wrapper managed-to-native) System.Threading.WaitHandle.WaitOne_internal (System.Threading.WaitHandle,intptr,int,bool) <0xffffffff>
  at System.Threading.WaitHandle.WaitOne () <0x00067>
  at Mono.Security.Protocol.Tls.SslStreamBase.EndNegotiateHandshake (Mono.Security.Protocol.Tls.SslStreamBase/InternalAsyncResult) <0x0002f>
  at Mono.Security.Protocol.Tls.SslStreamBase.NegotiateHandshake () <0x000ab>
  at Mono.Security.Protocol.Tls.SslStreamBase.Read (byte[],int,int) <0x00087>
  at System.IO.Stream.ReadByte () <0x0004a>
  at Novell.Directory.Ldap.Asn1.Asn1Identifier..ctor (System.IO.Stream) <0x00015>
  at Novell.Directory.Ldap.Connection/ReaderThread.Run () <0x0011b>
  at System.Threading.Thread.StartInternal () <0x00096>
  at (wrapper runtime-invoke) object.runtime_invoke_void__this__ (object,intptr,intptr,intptr) <0xffffffff>

"IO Threadpool worker"
"Threadpool monitor"
"<threadpool thread>"
"<unnamed thread>"  at <unknown> <0xffffffff>
  at (wrapper managed-to-native) System.Threading.WaitHandle.WaitOne_internal (System.Threading.WaitHandle,intptr,int,bool) <0xffffffff>
  at System.Threading.WaitHandle.WaitOne () <0x00067>
  at Mono.Security.Protocol.Tls.SslStreamBase.NegotiateHandshake () <0x0009d>
  at Mono.Security.Protocol.Tls.SslStreamBase.Write (byte[],int,int) <0x0007f>
  at Novell.Directory.Ldap.Connection.writeMessage (Novell.Directory.Ldap.LdapMessage) <0x00102>
  at Novell.Directory.Ldap.Connection.writeMessage (Novell.Directory.Ldap.Message) <0x00107>
  at Novell.Directory.Ldap.Message.sendMessage () <0x0001b>
  at Novell.Directory.Ldap.MessageAgent.sendMessage (Novell.Directory.Ldap.Connection,Novell.Directory.Ldap.LdapMessage,int,Novell.Directory.Ldap.LdapMessageQueue,Novell.Directory.Ldap.Utilclass.BindProperties) <0x00077>
  at Novell.Directory.Ldap.LdapConnection.SendRequestToServer (Novell.Directory.Ldap.LdapMessage,int,Novell.Directory.Ldap.LdapResponseQueue,Novell.Directory.Ldap.Utilclass.BindProperties) <0x000a7>
  at Novell.Directory.Ldap.LdapConnection.Bind (int,string,sbyte[],Novell.Directory.Ldap.LdapResponseQueue,Novell.Directory.Ldap.LdapConstraints,string) <0x00217>
  at Novell.Directory.Ldap.LdapConnection.Bind (int,string,sbyte[],Novell.Directory.Ldap.LdapConstraints) <0x0004d>
  at Novell.Directory.Ldap.LdapConnection.Bind (int,string,string,Novell.Directory.Ldap.LdapConstraints) <0x000b2>
  at Novell.Directory.Ldap.LdapConnection.Bind (string,string,Novell.Directory.Ldap.AuthenticationTypes) <0x00030>
  at Novell.Directory.Ldap.LdapConnection.Bind (string,string) <0x00029>
  at ConnectLdap.Main (string[]) <0x00086>
  at (wrapper runtime-invoke) <Module>.runtime_invoke_int_object (object,intptr,intptr,intptr) <0xffffffff>
Comment 1 Manuel Sugawara 2016-04-10 03:49:54 UTC
I've created a PR for this https://github.com/mono/mono/pull/2771
Comment 2 Miguel de Icaza [MSFT] 2016-04-10 13:52:41 UTC
Thank you Manuel, I saw that.

I raised the priority to have Martin review the change, and to integrate your fabulous test case.
Comment 3 Alexander Köplinger [MSFT] 2016-06-14 12:14:06 UTC
Seems like this wasn't correctly assigned to Martin yet, doing it now.
Comment 4 Martin Baulig 2016-11-11 10:36:41 UTC
I just triggered a build on the PR, we should merge it once it passes the tests.
Comment 5 Manuel Sugawara 2017-04-24 21:54:34 UTC
Any news on this ticket?
Comment 6 Martin Baulig 2017-09-13 19:15:42 UTC
Using legacy TLS, needs triage against current code.
Comment 7 Marek Safar 2018-03-13 11:07:30 UTC
We have not received the requested information. If you are still experiencing this issue please provide all the requested information and reopen the bug report.

Thank you!