G
Guest
If the following snippet of C# code is executed in a loop for a few 100,000
times – the CLR finally gives up and kills the thread:
try
{
// This will throw NullReferenceException
Convert.ChangeType( null, typeof(double) );
}
catch (Exception ex)
{
m_ExceptionCount++;
}
Some additional info:
- Number of exceptions to be thrown before the thread dies is not consistent
– in my tests it ranged from 100,000 to 2,000,000. Usually takes a few
minutes in specially built program for the thread to vanish. But in real-life
application it took a couple of days for the problem to show up – very nasty!
- In order for the problem to happen the processor needs to be loaded with
some background task. I had a second thread crunching some numbers to keep
the processor busy.
- When the thread vanishes there no exceptions caught by any try-catch
statement on the call stack. But current application domain raises an
UnhandledException event that can be caught when it is too late to save the
thread.
- The problem seems to be specific to 1.1 version of the framework – it does
not happen on 2.0. In fact, Convert.ChangeType does not throw
NullReferenceException on the later version.
Could someone confirm that this is a bug?
Is there are any other known cases when for this problem exists?
I have a simple Visual Studio 2003 project that consistently reproduces the
problem. If you would like to see the problem and do not feel like spending
time to build your own or have problems in reproducing it please contact me
directly – I will send you the code.
Thank you,
Alex.
times – the CLR finally gives up and kills the thread:
try
{
// This will throw NullReferenceException
Convert.ChangeType( null, typeof(double) );
}
catch (Exception ex)
{
m_ExceptionCount++;
}
Some additional info:
- Number of exceptions to be thrown before the thread dies is not consistent
– in my tests it ranged from 100,000 to 2,000,000. Usually takes a few
minutes in specially built program for the thread to vanish. But in real-life
application it took a couple of days for the problem to show up – very nasty!
- In order for the problem to happen the processor needs to be loaded with
some background task. I had a second thread crunching some numbers to keep
the processor busy.
- When the thread vanishes there no exceptions caught by any try-catch
statement on the call stack. But current application domain raises an
UnhandledException event that can be caught when it is too late to save the
thread.
- The problem seems to be specific to 1.1 version of the framework – it does
not happen on 2.0. In fact, Convert.ChangeType does not throw
NullReferenceException on the later version.
Could someone confirm that this is a bug?
Is there are any other known cases when for this problem exists?
I have a simple Visual Studio 2003 project that consistently reproduces the
problem. If you would like to see the problem and do not feel like spending
time to build your own or have problems in reproducing it please contact me
directly – I will send you the code.
Thank you,
Alex.