system hang debug

Hello everyone,

I met with a system hang issue (a program does not run to complete). It is a managed code program (C# console) and run on Windows Server 2003 x64. Are there any ideas or recommended documents about how to narrow down such hang problem?

thanks in advance,
George

George, why don’t you use Visual Studio for this? It would be a lot
easier to debug.

mm

Lin George wrote:

Hello everyone,

I met with a system hang issue (a program does not run to complete). It is a managed code program (C# console) and run on Windows Server 2003 x64. Are there any ideas or recommended documents about how to narrow down such hang problem?

thanks in advance,
George

Is it a system hang (the entire system is non-responsive) or just your
program?

Can you say something about the driver that it is using?

C# probably has little to do with the issue. Can you reproduce it if you
call your device from a straight Win32 program?
joe

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Lin George
Sent: Monday, January 19, 2009 1:55 AM
To: Kernel Debugging Interest List
Subject: [windbg] system hang debug

Hello everyone,

I met with a system hang issue (a program does not run to complete). It is a
managed code program (C# console) and run on Windows Server 2003 x64. Are
there any ideas or recommended documents about how to narrow down such hang
problem?

thanks in advance,
George


You are currently subscribed to windbg as: xxxxx@flounder.com To
unsubscribe send a blank email to xxxxx@lists.osr.com


This message has been scanned for viruses and dangerous content by
MailScanner, and is believed to be clean.

Hi Joseph,

Here is my code to reproduce it (the following code segment causes my application hang). You can change the localserver to google.com or ask.com to reproduce easy – after a couple of times of success, other operations are all timeout. Currently, the fix should be call close method n response.

My question is not about .Net (my apologies if it makes people confused), but using Windbg to debug leak issues and find the internal cause. I think it is either .Net bug which does not recycle the connection timely, or system has some limitations about open connection (I did not find such document after quite some time search)? I am so confused. Could you reproduce my problem at your side? Any insights?

?????? static void PingServers(Object state)  
??????? {  
??????????? HttpWebRequest request = (HttpWebRequest)WebRequest.Create((String)state);  
??????????? request.Timeout = 4 \* 1000;  
??????????? HttpWebResponse response = null;  
??????????? try  
??????????? {  
??????????????? response = (HttpWebResponse)request.GetResponse();  
??????????? }  
??????????? catch (WebException ex)  
??????????? {  
??????????????? Console.WriteLine((String)state + " " + ex.ToString());  
??? ??? ??? ??? //?response.Close();  
??????????????? return;  
??????????? }  
??????????? Console.WriteLine((String)state + " is healthy");  
??????????? //?response.Close();  
??????????? return;  
??????? }  
??????? static Timer[] monitorTimers = new Timer[2];  
???????   
??????? static void Main(string[] args)  
??????? {  
??????????? monitorTimers[0] = new Timer(PingServers, "http://localserver1/test/test.ashx", 0, 10 \* 1000);  
??????????? monitorTimers[1] = new Timer(PingServers, "http://localserver2/test/test.ashx", 0, 10 \* 1000);  
??????????? Console.ReadLine();  
??????????? return;  
??????? }  

regards,
George

----- Original Message ----
From: Joseph M. Newcomer
To: Kernel Debugging Interest List
Sent: Tuesday, January 20, 2009 1:48:28 AM
Subject: RE: [windbg] system hang debug

Is it a system hang (the entire system is non-responsive) or just your
program?

Can you say something about the driver that it is using?

C# probably has little to do with the issue.? Can you reproduce it if you
call your device from a straight Win32 program?
??? ??? ??? ??? joe

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Lin George
Sent: Monday, January 19, 2009 1:55 AM
To: Kernel Debugging Interest List
Subject: [windbg] system hang debug

Hello everyone,

I met with a system hang issue (a program does not run to complete). It is a
managed code program (C# console) and run on Windows Server 2003 x64. Are
there any ideas or recommended documents about how to narrow down such hang
problem?

thanks in advance,
George

? ? ?


You are currently subscribed to windbg as: xxxxx@flounder.com To
unsubscribe send a blank email to xxxxx@lists.osr.com


This message has been scanned for viruses and dangerous content by
MailScanner, and is believed to be clean.


You are currently subscribed to windbg as: xxxxx@yahoo.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

Thanks Martin,

I just use Visual Studio to build. And using Windbg and SOS to find the root cause. :slight_smile:

Here is my code to reproduce it (the following code segment causes my application hang). You can change the localserver to google.com or ask.com to reproduce easy – after a couple of times of success, other operations are all timeout. Currently, the fix should be call close method n response.

My question is not about .Net (my apologies if it makes people confused), but using Windbg to debug leak issues and find the internal cause. I think it is either .Net bug which does not recycle the connection timely, or system has some limitations about open connection (I did not find such document after quite some time search)? I am so confused. Could you reproduce my problem at your side? Any insights?

?????? static void PingServers(Object state)  
??????? {  
??????????? HttpWebRequest request = (HttpWebRequest)WebRequest.Create((String)state);  
??????????? request.Timeout = 4 \* 1000;  
??????????? HttpWebResponse response = null;  
??????????? try  
??????????? {  
??????????????? response = (HttpWebResponse)request.GetResponse();  
??????????? }  
??????????? catch (WebException ex)  
??????????? {  
??????????????? Console.WriteLine((String)state + " " + ex.ToString());  
??? ??? ??? ??? //?response.Close();  
??????????????? return;  
??????????? }  
??????????? Console.WriteLine((String)state + " is healthy");  
??????????? //?response.Close();  
??????????? return;  
??????? }  
??????? static Timer[] monitorTimers = new Timer[2];  
???????   
??????? static void Main(string[] args)  
??????? {  
??????????? monitorTimers[0] = new Timer(PingServers, "http://localserver1/test/test.ashx", 0, 10 \* 1000);  
??????????? monitorTimers[1] = new Timer(PingServers, "http://localserver2/test/test.ashx", 0, 10 \* 1000);  
??????????? Console.ReadLine();  
??????????? return;  
??????? }  

regards,
George

----- Original Message ----
From: Martin O’Brien
To: Kernel Debugging Interest List
Sent: Monday, January 19, 2009 6:49:49 PM
Subject: Re:[windbg] system hang debug

George, why don’t you use Visual Studio for this?? It would be a lot easier to debug.

mm

Lin George wrote:
> Hello everyone,
>
> I met with a system hang issue (a program does not run to complete). It is a managed code program (C# console) and run on Windows Server 2003 x64. Are there any ideas or recommended documents about how to narrow down such hang problem?
>
> thanks in advance,
> George
>
>
>? ? ?


You are currently subscribed to windbg as: xxxxx@yahoo.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

No hablo .NET. I have no idea what this code is trying to do. So I =
cannot
tell why it is not working. .NET puts so many layers between the source =
and
the Win32 API that it would be hard to tell what is wrong. For example, =
if
you break into the program, where is it hung? It could be looping =
inside
your app for .NET reasons, for all I can tell. If it is not an =
interaction
with a specific driver, then it is a .NET problem, which is why I asked =
if
you could reproduce it in Win32. I had presumed that you had written =
the
driver that was involved in this. But if I can reproduce it without =
your
driver, it is probably *not* a driver problem, but some issue in the =
.NET
libraries. See the first sentence.
joe
=20

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Lin George
Sent: Tuesday, January 20, 2009 1:10 AM
To: Kernel Debugging Interest List
Cc: Kernel Debugging Interest List
Subject: Re: [windbg] system hang debug

Hi Joseph,

Here is my code to reproduce it (the following code segment causes my
application hang). You can change the localserver to google.com or =
ask.com
to reproduce easy – after a couple of times of success, other =
operations
are all timeout. Currently, the fix should be call close method n =
response.

My question is not about .Net (my apologies if it makes people =
confused),
but using Windbg to debug leak issues and find the internal cause. I =
think
it is either .Net bug which does not recycle the connection timely, or
system has some limitations about open connection (I did not find such
document after quite some time search)? I am so confused. Could you
reproduce my problem at your side? Any insights?

=A0=A0=A0=A0=A0=A0 static void PingServers(Object state)  
=A0=A0=A0=A0=A0=A0=A0 {  
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 HttpWebRequest request =3D  
(HttpWebRequest)WebRequest.Create((String)state);  
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 request.Timeout =3D 4 \* 1000;  
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 HttpWebResponse response =3D null;  
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 try  
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 {  
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 response =3D =  
(HttpWebResponse)request.GetResponse();  
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 }  
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 catch (WebException ex)  
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 {  
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 =  
Console.WriteLine((String)state + " " + ex.ToString());  
=A0=A0=A0 =A0=A0=A0 =A0=A0=A0 =A0=A0=A0 //=A0response.Close();  
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 return;  
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 }  
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 Console.WriteLine((String)state + " is =  
healthy");  
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 //=A0response.Close();  
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 return;  
=A0=A0=A0=A0=A0=A0=A0 }  
=A0=A0=A0=A0=A0=A0=A0 static Timer[] monitorTimers =3D new Timer[2];  
=A0=A0=A0=A0=A0=A0=A0=20  
=A0=A0=A0=A0=A0=A0=A0 static void Main(string[] args)  
=A0=A0=A0=A0=A0=A0=A0 {  
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 monitorTimers[0] =3D new =  
Timer(PingServers,  
"http://localserver1/test/test.ashx", 0, 10 \* 1000);  
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 monitorTimers[1] =3D new =  
Timer(PingServers,  
"http://localserver2/test/test.ashx", 0, 10 \* 1000);  
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 Console.ReadLine();  
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 return;  
=A0=A0=A0=A0=A0=A0=A0 }  

regards,
George

----- Original Message ----
From: Joseph M. Newcomer
To: Kernel Debugging Interest List
Sent: Tuesday, January 20, 2009 1:48:28 AM
Subject: RE: [windbg] system hang debug

Is it a system hang (the entire system is non-responsive) or just your
program?

Can you say something about the driver that it is using?

C# probably has little to do with the issue.=A0 Can you reproduce it if =
you
call your device from a straight Win32 program?=20
=A0=A0=A0 =A0=A0=A0 =A0=A0=A0 =A0=A0=A0 joe

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Lin George
Sent: Monday, January 19, 2009 1:55 AM
To: Kernel Debugging Interest List
Subject: [windbg] system hang debug

Hello everyone,

I met with a system hang issue (a program does not run to complete). It =
is a
managed code program (C# console) and run on Windows Server 2003 x64. =
Are
there any ideas or recommended documents about how to narrow down such =
hang
problem?

thanks in advance,
George

=A0 =A0 =A0=20


You are currently subscribed to windbg as: xxxxx@flounder.com To
unsubscribe send a blank email to xxxxx@lists.osr.com


This message has been scanned for viruses and dangerous content by
MailScanner, and is believed to be clean.


You are currently subscribed to windbg as: xxxxx@yahoo.com To
unsubscribe send a blank email to xxxxx@lists.osr.com

=20


You are currently subscribed to windbg as: unknown lmsubst tag argument: =
‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com


This message has been scanned for viruses and dangerous content by
MailScanner, and is believed to be clean.

Lin George wrote:

Thanks Martin,

I just use Visual Studio to build. And using Windbg and SOS to find the root cause. :slight_smile:

Here is my code to reproduce it (the following code segment causes my application hang). You can change the localserver to google.com or ask.com to reproduce easy – after a couple of times of success, other operations are all timeout. Currently, the fix should be call close method n response.

Right. That’s the fix for YOUR bug.

My question is not about .Net (my apologies if it makes people confused),

Actually, yes, it is.

…but using Windbg to debug leak issues and find the internal cause. I think it is either .Net bug which does not recycle the connection timely, or system has some limitations about open connection (I did not find such document after quite some time search)?

This is not a .NET bug at all. It is a misunderstanding on your part.
You are accustomed to thinking about C++. In C++, when an object goes
out of scope, it is destroyed at once. The destructors run immediately,
and the WebRequest here would close the socket and clean up before the
next statement ran.

That’s NOT how C# works. In C#, when an object goes out of scope, it
will be marked as “unused”, but it will not be destroyed until the
garbage collector runs at some unpredictable time in the future –
possibly LONG in the future. Until it is collected, the object is still
alive. This is called “non-deterministic destruction”.

In a case like this, where you have a resource that needs to be cleaned
up immediately, you either need to call something like the “Close”
method yourself, or use the “using” statement.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.