Abnormal Thread Termination

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



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
.



Relevant Pages

  • Re: Application.Run() Application.Exit and the Message Pump
    ... it may not be appropriate to start another message pump in most real-world scenerios. ... > execution is "blocked" until you click close. ... Then finally, the application terminates. ... > Question - The closing of the first form does not 'mortally ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Very confused by Ada tasking, can not explain the execution outcome.
    ... is never executed, but the task terminates. ... The only procedure increment ... 'rounds' is procedure 'use_res', but the procedure was never called ... the task execution, ...
    (comp.lang.ada)
  • Abnormal Thread Termination
    ... only once in 6000 similar execution (through same code path). ... thread abnormally terminates when executing .NET method. ... methods where I am using IO Stream operation. ...
    (microsoft.public.dotnet.languages.csharp)
  • Abnormal Thread Termination
    ... only once in 6000 similar execution (through same code path). ... thread abnormally terminates when executing .NET method. ... methods where I am using IO Stream operation. ...
    (microsoft.public.dotnet.framework.interop)
  • Re: is C implementation allowed to terminate an infinite loop?
    ... identical to the result that execution of the program according ... -- The input and output dynamics of interactive devices shall take ... The standard only requires file data to be consistent "At program ... If stdout is a file, then yes, the program is free to write arbitrary junk to it as long as it makes sure that the file contains the expected data when the program terminates, *if* it ever terminates. ...
    (comp.std.c)