Abnormal Thread Termination
- From: "Rahul Anand" <RahulAnand@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Fri, 15 Jul 2005 03:56:05 -0700
I have a problem in my multithreaded application. The problem is reproducible
very rarely, only once in 6000 similar execution (through same code path).
Problem: One of multiple threads gets abnormally terminated. It does not go
through the try-catch-finally sequence. The mehtod gets hanged and the object
used inside the method gets collected by GC.
Background about the Application: I am using COM-Interop. The threads are
created in unmanaged code which calls methods from managed code. One of the
thread abnormally terminates when executing .NET method.
Observation: I have observed that the thread terminates only in those
methods where I am using IO Stream operation.
As I said this is very rare and the same code works fine except once or
twice in 6000 executions.
This is the code under which thread terminates mostly.
<CODE>
// I am generating log file for comments, to see the actual execution path
public string GetRequestFile(string strFileName)
{
// Log method enterd
StreamReader reader = null;
try
{
reader = new StreamReader(strFileName);
return reader.ReadToEnd();
}
catch(Exception exc)
{
// Log error occurred
throw;
}
finally
{
if(reader != null)
reader.Close();
// Log finally executed
}
}
<CODE>
Please let me know if there is any similar bug reported under .NET I/O
Stream operation.
Does CLR forcefully terminates a thread in a way that it bypasses the
finally block?
Thanks in advance for your help.
Cheers,
Rahul Anand
.
- Follow-Ups:
- Re: Abnormal Thread Termination
- From: Jim
- Re: Abnormal Thread Termination
- From: Mrinal Kamboj
- Re: Abnormal Thread Termination
- Prev by Date: Re: Side-by-side, within an app
- Next by Date: Re: Abnormal Thread Termination
- Previous by thread: Side-by-side, within an app
- Next by thread: Re: Abnormal Thread Termination
- Index(es):
Relevant Pages
|