Abnormal Thread Termination

G

Guest

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
goes through the try-catch-finally sequence. The mehtod gets hanged and the
object used inside the method gets collected by GC.

Bacground 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.

Thanks in advance for your help.

Cheers,
Rahul Anand
 
A

Alvin Bruney [MVP - ASP.NET]

stop cross posting, you already got two replies in the other newsgroup. did
you check these solutions before posting here?

--
Regards,
Alvin Bruney - ASP.NET MVP

[Shameless Author Plug]
The Microsoft Office Web Components Black Book with .NET
Now available @ www.lulu.com/owc, Amazon.com etc
 
G

Guest

Hi Alvin,

I have posted my problem in this group and at the same time in other gorups
related to CLR and INTEROP as I was not sure where I can get a solution. And
the problem is related to C#, and HowThreading is Handled by CLR, and also
the scenario involves of COM-InterOP. Therefore I have posted my problem to
all related groups so that all related community will be benifitted with this
discussion.

Regards,
Rahul Anand

Alvin Bruney said:
stop cross posting, you already got two replies in the other newsgroup. did
you check these solutions before posting here?

--
Regards,
Alvin Bruney - ASP.NET MVP

[Shameless Author Plug]
The Microsoft Office Web Components Black Book with .NET
Now available @ www.lulu.com/owc, Amazon.com etc
Rahul Anand said:
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
goes through the try-catch-finally sequence. The mehtod gets hanged and
the
object used inside the method gets collected by GC.

Bacground 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.

Thanks in advance for your help.

Cheers,
Rahul Anand
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top