dotgnu-pnet
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [Pnet-developers] exception patches


From: Thong (Tum) Nguyen
Subject: RE: [Pnet-developers] exception patches
Date: Mon, 24 May 2004 11:45:18 +1200

Hi Rhys,

I'm glad you're looking into this :).  It's been bugging me for a day now
and I thought I might save you some time be describing what I've found out
so far and how I've attempted to fix it.  Consider the following code:

try
{
   try
   {
   }
   catch (B)
   {
      try
      {
         throw new A();
      }
      catch (C)
      {
      }
   }
}
catch (A)
{
}

The exception table is processed in the order C, B, A.  When the exception
(A) is thrown, C can't catch it so it "falls through" to the next part of
the exception table (to the next entry) which is the code for "B".  Because
CVM stores things like the start/end/length of the catch *before* actual CVM
instructions for the actual check (the DUP and ISINST instructions), I have
had to add an additional branch (COP_BR) to skip CVM_LEN_TRY instructions.
This however, highlighted another problem.  The part of the exception table
for "B" that comes after the part for "C" shouldn't be the one trying to
catch the "A" exception since it was thrown from within the "catch" block
and not within the "try" block.  To solve this, I used an array in
ILCVMCoder to keep track of the generated branch-placeholder points for the
end of every try/catch region that is within a catch block.  These
branch-placeholder points are backpatched after the "catch B" block (the
first handler region that's not within a catch region).  This means that
when if an exception can't be caught by the "C" handler, it will jump to and
execute the "A" handler (the first handler that isn't within a catch clause)
rather than into the next (B) handler (the current implementation doesn't
skip B's TryStart code so it tries to execute CVM arguments rather than CVM
code).

I've implemented it (I needed it to get my Thread.Abort tests working) and
it does seem to work but there might be things I've overlooked.

Regards,

^Tum

> -----Original Message-----
> From: Rhys Weatherley [mailto:address@hidden
> Sent: Monday, 24 May 2004 10:29 a.m.
> To: address@hidden
> Subject: [Pnet-developers] exception patches
> 
> Gopal just applied Jonas' exception patch, which I said to do so on
> Saturday.
> 
> However, since then, Tum has discovered serious problems with both Jonas'
> and
> Rich' patches that I did not notice during my code review.
> 
> I have reversed the patch that Gopal applied, and I will investigate the
> problem myself today.
> 
> Cheers,
> 
> Rhys.
> 
> _______________________________________________
> Pnet-developers mailing list
> address@hidden
> http://dotgnu.org/mailman/listinfo/pnet-developers



reply via email to

[Prev in Thread] Current Thread [Next in Thread]